Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
e92a911e
Commit
e92a911e
authored
Mar 11, 2016
by
Abiola Ibrahim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more tests.
parent
84845a66
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
middleware/fileserver.go
middleware/fileserver.go
+1
-0
middleware/fileserver_test.go
middleware/fileserver_test.go
+20
-0
No files found.
middleware/fileserver.go
View file @
e92a911e
...
...
@@ -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
...
...
middleware/fileserver_test.go
View file @
e92a911e
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment