diff Lib/SimpleHTTPServer.py @ 33214:d9765eb59edd legacy-trunk

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'.
author Johannes Gijsbers <jlg@dds.nl>
date Sat, 21 Aug 2004 10:43:29 +0000
parents 0beb756965df
children 18cff3ed74d3 cd517701fd93
line wrap: on
line diff
--- a/Lib/SimpleHTTPServer.py	Sat Aug 21 06:55:43 2004 +0000
+++ b/Lib/SimpleHTTPServer.py	Sat Aug 21 10:43:29 2004 +0000
@@ -105,7 +105,7 @@
         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 @@
             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)