diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2013-09-13 07:21:18 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2013-09-13 07:21:18 (GMT) |
commit | 72c238e21ae78f8da969c46a2b7317ff9904d155 (patch) | |
tree | d79545c48462a5b81abc233044c026b8e2075678 /Lib/http/server.py | |
parent | 016af3f4d484d0e4f756bf0a505d0df3cbc444ed (diff) | |
download | cpython-72c238e21ae78f8da969c46a2b7317ff9904d155.zip cpython-72c238e21ae78f8da969c46a2b7317ff9904d155.tar.gz cpython-72c238e21ae78f8da969c46a2b7317ff9904d155.tar.bz2 |
Fix http.server's request handling case on trailing '/'.
Patch contributed by Vajrasky Kok. Addresses Issue #17324
Diffstat (limited to 'Lib/http/server.py')
-rw-r--r-- | Lib/http/server.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/http/server.py b/Lib/http/server.py index c4ac703..195f9ee 100644 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -780,6 +780,8 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): # abandon query parameters path = path.split('?',1)[0] path = path.split('#',1)[0] + # Don't forget explicit trailing slash when normalizing. Issue17324 + trailing_slash = True if path.rstrip().endswith('/') else False path = posixpath.normpath(urllib.parse.unquote(path)) words = path.split('/') words = filter(None, words) @@ -789,6 +791,8 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): head, word = os.path.split(word) if word in (os.curdir, os.pardir): continue path = os.path.join(path, word) + if trailing_slash: + path += '/' return path def copyfile(self, source, outputfile): |