1
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-16 21:56:40 -05:00

caddyhttp: Add test cases to corpus (#6374)

* caddyhttp: Add test case to corpus

* One more test case

* Clean up stray comment

* More tests
This commit is contained in:
Matt Holt 2024-06-04 14:23:55 -06:00 committed by GitHub
parent e7ecc7ede2
commit 198f4385d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -94,7 +94,31 @@ func TestSanitizedPathJoin(t *testing.T) {
inputRoot: "C:\\www", inputRoot: "C:\\www",
inputPath: "/D:\\foo\\bar", inputPath: "/D:\\foo\\bar",
expect: filepath.Join("C:\\www", "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 // https://github.com/golang/go/issues/56336#issuecomment-1416214885