diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py index 3f800ef..467c5c4 100644 --- a/Lib/test/test_wsgiref.py +++ b/Lib/test/test_wsgiref.py @@ -221,6 +221,29 @@ class IntegrationTests(TestCase): b"data", out) + def test_cp1252_url(self): + def app(e, s): + s("200 OK", [ + ("Content-Type", "text/plain"), + ("Date", "Wed, 24 Dec 2008 13:29:32 GMT"), + ]) + # PEP3333 says environ variables are decoded as latin1 + # encode as latin1 to get original bytes + return [e["PATH_INFO"].encode("latin1")] + + out, err = run_amock(validator(app), data=b"GET /\x80 HTTP/1.0") + ver = sys.version.split()[0].encode('ascii') + py = python_implementation().encode('ascii') + pyver = py + b"/" + ver + self.assertEqual( + b"HTTP/1.0 200 OK\r\n" + b"Server: WSGIServer/0.2 "+ pyver + b"\r\n" + b"Content-Type: text/plain\r\n" + b"Date: Wed, 24 Dec 2008 13:29:32 GMT\r\n" + b"\r\n" + b"/\x80", + out) + class UtilityTests(TestCase): diff --git a/Lib/wsgiref/simple_server.py b/Lib/wsgiref/simple_server.py index 378b316..6e020dc 100644 --- a/Lib/wsgiref/simple_server.py +++ b/Lib/wsgiref/simple_server.py @@ -82,7 +82,7 @@ class WSGIRequestHandler(BaseHTTPRequestHandler): else: path,query = self.path,'' - env['PATH_INFO'] = urllib.parse.unquote_to_bytes(path).decode('iso-8859-1') + env['PATH_INFO'] = urllib.parse.unquote(path) env['QUERY_STRING'] = query host = self.address_string()