Skip to content

Commit e750aa8

Browse files
committed
fix: Normalize location path to avoid multiple forward slashes
Fixes: #88
1 parent c7db9c9 commit e750aa8

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

common/etc/nginx/templates/default.conf.template

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ server {
3030
# information that could be used to find an exploit.
3131
server_tokens off;
3232

33+
# Normalize location path. Remove instances of double/multipe forward slashes.
34+
# Disabling merge_slashes is necessary for this feature to work.
35+
# Disabling port redirection to avoid broken URLs in bridged hosts
36+
port_in_redirect off;
37+
merge_slashes off;
38+
rewrite (.*?)//+(.*) $1/$2 redirect;
39+
3340
# Uncomment this for a HTTP header that will let you know the cache status
3441
# of an object.
3542
# add_header X-Cache-Status $upstream_cache_status;

test/integration/test_api.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ assertHttpRequestEquals "HEAD" "a.txt?some=param&that=should&be=stripped#aaah" "
153153
assertHttpRequestEquals "HEAD" "b/c/d.txt" "200"
154154
assertHttpRequestEquals "HEAD" "b/c/../e.txt" "200"
155155
assertHttpRequestEquals "HEAD" "b/e.txt" "200"
156-
assertHttpRequestEquals "HEAD" "b//e.txt" "200"
156+
assertHttpRequestEquals "HEAD" "b//e.txt" "302"
157157
assertHttpRequestEquals "HEAD" "a/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.txt" "200"
158158

159159
# We try to request URLs that are properly encoded as well as URLs that
@@ -220,11 +220,7 @@ fi
220220
assertHttpRequestEquals "HEAD" "b/" "404"
221221
assertHttpRequestEquals "HEAD" "/b/c/" "404"
222222
assertHttpRequestEquals "HEAD" "/soap" "404"
223-
if [ "${append_slash}" == "1" ] && [ "${index_page}" == "0" ]; then
224223
assertHttpRequestEquals "HEAD" "b//c" "302"
225-
else
226-
assertHttpRequestEquals "HEAD" "b//c" "404"
227-
fi
228224

229225
if [ "${index_page}" == "1" ]; then
230226
assertHttpRequestEquals "HEAD" "/statichost/" "200"

0 commit comments

Comments
 (0)