summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2011-03-17 04:34:18 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2011-03-17 04:34:18 (GMT)
commit3853586e0caa0d5c4342ac8bd7e78cb5766fa8cc (patch)
tree65d9037264f41d41a5977155403cb96abac3ff2a
parent6e0a8b8ab63cc60b39af4387b99f448b0cf137ad (diff)
downloadcpython-3853586e0caa0d5c4342ac8bd7e78cb5766fa8cc.zip
cpython-3853586e0caa0d5c4342ac8bd7e78cb5766fa8cc.tar.gz
cpython-3853586e0caa0d5c4342ac8bd7e78cb5766fa8cc.tar.bz2
Fix issue11442 - Add a charset parameter to the Content-type to avoid XSS attacks.
Patch by Tom N. (Backported from py3k codeline).
-rw-r--r--Lib/SimpleHTTPServer.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/SimpleHTTPServer.py b/Lib/SimpleHTTPServer.py
index 86c669e..286731d 100644
--- a/Lib/SimpleHTTPServer.py
+++ b/Lib/SimpleHTTPServer.py
@@ -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