diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2008-02-28 14:03:03 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2008-02-28 14:03:03 (GMT) |
commit | a6298528e1f5c10abd0d4255ef911179e9b1b912 (patch) | |
tree | be858b72d2e060ceec780fa1a20cf6d4f57a6d9d | |
parent | cdddf187685cde1b2dba3d37aa180191bc254e58 (diff) | |
download | cpython-a6298528e1f5c10abd0d4255ef911179e9b1b912.zip cpython-a6298528e1f5c10abd0d4255ef911179e9b1b912.tar.gz cpython-a6298528e1f5c10abd0d4255ef911179e9b1b912.tar.bz2 |
#2169: make generated HTML more valid
-rw-r--r-- | Lib/SimpleHTTPServer.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/SimpleHTTPServer.py b/Lib/SimpleHTTPServer.py index 7b6e867..e79a478 100644 --- a/Lib/SimpleHTTPServer.py +++ b/Lib/SimpleHTTPServer.py @@ -112,8 +112,9 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): list.sort(key=lambda a: a.lower()) f = StringIO() 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('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">') + f.write("<html>\n<title>Directory listing for %s</title>\n" % displaypath) + f.write("<body>\n<h2>Directory listing for %s</h2>\n" % displaypath) f.write("<hr>\n<ul>\n") for name in list: fullname = os.path.join(path, name) @@ -127,7 +128,7 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): # Note: a link to a directory displays with @ and links with / f.write('<li><a href="%s">%s</a>\n' % (urllib.quote(linkname), cgi.escape(displayname))) - f.write("</ul>\n<hr>\n") + f.write("</ul>\n<hr>\n</body>\n</html>\n") length = f.tell() f.seek(0) self.send_response(200) |