mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Fix http.server's request handling case on trailing '/'.
Patch contributed by Vajrasky Kok. Addresses Issue #17324
This commit is contained in:
parent
016af3f4d4
commit
72c238e21a
3 changed files with 11 additions and 0 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue