mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
Add more tests.
This commit is contained in:
parent
84845a66ab
commit
e92a911e7d
2 changed files with 21 additions and 0 deletions
|
@ -141,6 +141,7 @@ func (fh fileHandler) isHidden(name string) bool {
|
|||
name = strings.TrimSpace(name)
|
||||
for strings.HasSuffix(name, ".") {
|
||||
name = name[:len(name)-1]
|
||||
name = strings.TrimSpace(name)
|
||||
}
|
||||
}
|
||||
// If the file is supposed to be hidden, return a 404
|
||||
|
|
|
@ -112,6 +112,26 @@ func TestServeHTTP(t *testing.T) {
|
|||
expectedStatus: http.StatusMovedPermanently,
|
||||
expectedBodyContent: movedPermanently,
|
||||
},
|
||||
// Test 11 - attempt to bypass hidden file
|
||||
{
|
||||
url: "https://foo/dir/hidden.html%20",
|
||||
expectedStatus: http.StatusNotFound,
|
||||
},
|
||||
// Test 12 - attempt to bypass hidden file
|
||||
{
|
||||
url: "https://foo/dir/hidden.html.",
|
||||
expectedStatus: http.StatusNotFound,
|
||||
},
|
||||
// Test 13 - attempt to bypass hidden file
|
||||
{
|
||||
url: "https://foo/dir/hidden.html.%20",
|
||||
expectedStatus: http.StatusNotFound,
|
||||
},
|
||||
// Test 14 - attempt to bypass hidden file
|
||||
{
|
||||
url: "https://foo/dir/hidden.html%20.",
|
||||
expectedStatus: http.StatusNotFound,
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
|
|
Loading…
Reference in a new issue