summaryrefslogtreecommitdiff
path: root/Lib/http/server.py
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2013-09-13 00:22:45 -0700
committerSenthil Kumaran <senthil@uthcode.com>2013-09-13 00:22:45 -0700
commit09cc5edb913ee8c0f6a9f64a3590561248da0f60 (patch)
treee34730775014b9c312148c3ac995fd0f260d2d47 /Lib/http/server.py
parent1d76d2fd99e6493343dfab88a6bf15d5c7b0f0a1 (diff)
parente7b1dc96fc3b244f6a7399c5dc234423327de1b0 (diff)
downloadcpython-09cc5edb913ee8c0f6a9f64a3590561248da0f60.tar.gz
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.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/http/server.py b/Lib/http/server.py
index e47e034feb..87d83784ed 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):