mirror of
https://github.com/python/cpython.git
synced 2024-12-03 06:46:01 +08:00
Patch #1011123: Use urllib.quote() instead of cgi.escape() for encoding the
href attribute in list_directory(). This fixes the links for legal Unix filenames such as 'a"b'.
This commit is contained in:
parent
037b3ee44e
commit
6d63a8dd09
@ -105,7 +105,7 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||
f.write("<hr>\n<ul>\n")
|
||||
for name in list:
|
||||
fullname = os.path.join(path, name)
|
||||
displayname = linkname = name = cgi.escape(name)
|
||||
displayname = linkname = name
|
||||
# Append / for directories or @ for symbolic links
|
||||
if os.path.isdir(fullname):
|
||||
displayname = name + "/"
|
||||
@ -113,7 +113,8 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
||||
if os.path.islink(fullname):
|
||||
displayname = name + "@"
|
||||
# Note: a link to a directory displays with @ and links with /
|
||||
f.write('<li><a href="%s">%s</a>\n' % (linkname, displayname))
|
||||
f.write('<li><a href="%s">%s</a>\n'
|
||||
% (urllib.quote(linkname), cgi.escape(displayname)))
|
||||
f.write("</ul>\n<hr>\n")
|
||||
length = f.tell()
|
||||
f.seek(0)
|
||||
|
Loading…
Reference in New Issue
Block a user