]> granicus.if.org Git - python/commitdiff
Patch #1360443: Make SimpleHTTPServer display unencoded directory names.
authorGeorg Brandl <georg@python.org>
Fri, 16 Dec 2005 19:36:08 +0000 (19:36 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 16 Dec 2005 19:36:08 +0000 (19:36 +0000)
Lib/SimpleHTTPServer.py

index 93af10900aae2916cd9049922b2fd3a06cec0eb4..eac95cab96a774a873e6978a667d9b91e8256c5a 100644 (file)
@@ -103,8 +103,9 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
             return None
         list.sort(key=lambda a: a.lower())
         f = StringIO()
-        f.write("<title>Directory listing for %s</title>\n" % self.path)
-        f.write("<h2>Directory listing for %s</h2>\n" % self.path)
+        displaypath = cgi.escape(urllib.unquote(self.path))
+        f.write("<title>Directory listing for %s</title>\n" % displaypath)
+        f.write("<h2>Directory listing for %s</h2>\n" % displaypath)
         f.write("<hr>\n<ul>\n")
         for name in list:
             fullname = os.path.join(path, name)