diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2013-09-13 07:22:45 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2013-09-13 07:22:45 (GMT) |
commit | 187b06300518d35d04454238c240fdfd28864141 (patch) | |
tree | 58fd441d9468e0fc35a4d707c55f1c10b6d66656 /Lib/http | |
parent | 5abf3d9926be2c84d80e4c2bc775f175521a8a38 (diff) | |
parent | 72c238e21ae78f8da969c46a2b7317ff9904d155 (diff) | |
download | cpython-187b06300518d35d04454238c240fdfd28864141.zip cpython-187b06300518d35d04454238c240fdfd28864141.tar.gz cpython-187b06300518d35d04454238c240fdfd28864141.tar.bz2 |
Fix http.server's request handling case on trailing '/'.
Patch contributed by Vajrasky Kok. Addresses Issue #17324
Diffstat (limited to 'Lib/http')
-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 e47e034..87d8378 100644 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -788,6 +788,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) @@ -797,6 +799,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): |