summaryrefslogtreecommitdiff
path: root/Lib/SimpleHTTPServer.py
diff options
context:
space:
mode:
authorJohannes Gijsbers <jlg@dds.nl>2004-08-21 10:43:29 +0000
committerJohannes Gijsbers <jlg@dds.nl>2004-08-21 10:43:29 +0000
commit0e4340b17b973c0722abc8c0de557d431e43e98e (patch)
treefe74657c4033999f826dbcbee936af5046c184a9 /Lib/SimpleHTTPServer.py
parent9f9125279162c335776e9e91d06ecc2ca2d40f84 (diff)
downloadcpython-0e4340b17b973c0722abc8c0de557d431e43e98e.tar.gz
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'.
Diffstat (limited to 'Lib/SimpleHTTPServer.py')
-rw-r--r--Lib/SimpleHTTPServer.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/SimpleHTTPServer.py b/Lib/SimpleHTTPServer.py
index d58f52fda0..93662ab194 100644
--- a/Lib/SimpleHTTPServer.py
+++ b/Lib/SimpleHTTPServer.py
@@ -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)