Fix issue11442 - Add a charset parameter to the Content-type to avoid XSS attacks.

Patch by Tom N. (Backported from py3k codeline).
This commit is contained in:
Senthil Kumaran 2011-03-17 12:34:18 +08:00
parent 6e0a8b8ab6
commit 3853586e0c

View file

@ -16,6 +16,7 @@ import BaseHTTPServer
import urllib
import urlparse
import cgi
import sys
import shutil
import mimetypes
try:
@ -132,7 +133,8 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
length = f.tell()
f.seek(0)
self.send_response(200)
self.send_header("Content-type", "text/html")
encoding = sys.getfilesystemencoding()
self.send_header("Content-type", "text/html; charset=%s" % encoding)
self.send_header("Content-Length", str(length))
self.end_headers()
return f