Skip to content

Commit d77133b

Browse files
committed
Issue python#26717: Merge wsgiref fix from 3.5
2 parents 528619b + 50dd1f7 commit d77133b

4 files changed

Lines changed: 29 additions & 1 deletion

File tree

Lib/test/test_wsgiref.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from unittest import mock
12
from unittest import TestCase
23
from wsgiref.util import setup_testing_defaults
34
from wsgiref.headers import Headers
@@ -221,6 +222,29 @@ def app(e, s):
221222
b"data",
222223
out)
223224

225+
def test_cp1252_url(self):
226+
def app(e, s):
227+
s("200 OK", [
228+
("Content-Type", "text/plain"),
229+
("Date", "Wed, 24 Dec 2008 13:29:32 GMT"),
230+
])
231+
# PEP3333 says environ variables are decoded as latin1.
232+
# Encode as latin1 to get original bytes
233+
return [e["PATH_INFO"].encode("latin1")]
234+
235+
out, err = run_amock(
236+
validator(app), data=b"GET /\x80%80 HTTP/1.0")
237+
self.assertEqual(
238+
[
239+
b"HTTP/1.0 200 OK",
240+
mock.ANY,
241+
b"Content-Type: text/plain",
242+
b"Date: Wed, 24 Dec 2008 13:29:32 GMT",
243+
b"",
244+
b"/\x80\x80",
245+
],
246+
out.splitlines())
247+
224248

225249
class UtilityTests(TestCase):
226250

Lib/wsgiref/simple_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def get_environ(self):
8282
else:
8383
path,query = self.path,''
8484

85-
env['PATH_INFO'] = urllib.parse.unquote_to_bytes(path).decode('iso-8859-1')
85+
env['PATH_INFO'] = urllib.parse.unquote(path, 'iso-8859-1')
8686
env['QUERY_STRING'] = query
8787

8888
host = self.address_string()

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,7 @@ Nir Soffer
13851385
Paul Sokolovsky
13861386
Evgeny Sologubov
13871387
Cody Somerville
1388+
Anthony Sottile
13881389
Edoardo Spadolini
13891390
Geoffrey Spear
13901391
Clay Spence

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ Core and Builtins
245245
Library
246246
-------
247247

248+
- Issue #26717: Stop encoding Latin-1-ized WSGI paths with UTF-8. Patch by
249+
Anthony Sottile.
250+
248251
- Issue #26782: Add STARTUPINFO to subprocess.__all__ on Windows.
249252

250253
- Issue #26404: Add context manager to socketserver. Patch by Aviv Palivoda.

0 commit comments

Comments
 (0)