diff --git a/Lib/SimpleHTTPServer.py b/Lib/SimpleHTTPServer.py
index d58f52fda0d..93662ab1948 100644
--- a/Lib/SimpleHTTPServer.py
+++ b/Lib/SimpleHTTPServer.py
@@ -105,7 +105,7 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
f.write("
\n\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('- %s\n' % (linkname, displayname))
+ f.write('
- %s\n'
+ % (urllib.quote(linkname), cgi.escape(displayname)))
f.write("
\n
\n")
length = f.tell()
f.seek(0)