aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMatt Holt <[email protected]>2024-06-04 14:23:55 -0600
committerGitHub <[email protected]>2024-06-04 14:23:55 -0600
commit198f4385d2f72ccdd853825270f601bea7a7a190 (patch)
tree0c3a95a483e2fa77dfb7e2c7f88265577d37f046
parente7ecc7ede2f0f749530b0c2e685b99954b9591ce (diff)
downloadcaddy-198f4385d2f72ccdd853825270f601bea7a7a190.tar.gz
caddy-198f4385d2f72ccdd853825270f601bea7a7a190.zip
caddyhttp: Add test cases to corpus (#6374)
* caddyhttp: Add test case to corpus * One more test case * Clean up stray comment * More tests
-rw-r--r--modules/caddyhttp/caddyhttp_test.go26
1 files changed, 25 insertions, 1 deletions
diff --git a/modules/caddyhttp/caddyhttp_test.go b/modules/caddyhttp/caddyhttp_test.go
index 0062c6711..aeed0135c 100644
--- a/modules/caddyhttp/caddyhttp_test.go
+++ b/modules/caddyhttp/caddyhttp_test.go
@@ -94,7 +94,31 @@ func TestSanitizedPathJoin(t *testing.T) {
inputRoot: "C:\\www",
inputPath: "/D:\\foo\\bar",
expect: filepath.Join("C:\\www", "D:\\foo\\bar"),
- expectWindows: filepath.Join("C:\\www"), // inputPath fails IsLocal on Windows
+ expectWindows: "C:\\www", // inputPath fails IsLocal on Windows
+ },
+ {
+ inputRoot: `C:\www`,
+ inputPath: `/..\windows\win.ini`,
+ expect: `C:\www/..\windows\win.ini`,
+ expectWindows: `C:\www`,
+ },
+ {
+ inputRoot: `C:\www`,
+ inputPath: `/..\..\..\..\..\..\..\..\..\..\windows\win.ini`,
+ expect: `C:\www/..\..\..\..\..\..\..\..\..\..\windows\win.ini`,
+ expectWindows: `C:\www`,
+ },
+ {
+ inputRoot: `C:\www`,
+ inputPath: `/..%5cwindows%5cwin.ini`,
+ expect: `C:\www/..\windows\win.ini`,
+ expectWindows: `C:\www`,
+ },
+ {
+ inputRoot: `C:\www`,
+ inputPath: `/..%5c..%5c..%5c..%5c..%5c..%5c..%5c..%5c..%5c..%5cwindows%5cwin.ini`,
+ expect: `C:\www/..\..\..\..\..\..\..\..\..\..\windows\win.ini`,
+ expectWindows: `C:\www`,
},
{
// https://github.com/golang/go/issues/56336#issuecomment-1416214885