Skip to content

Commit 3d64c89

Browse files
committed
Unquote PATH_INFO in wsgi.
Closes tornadoweb#281 Closes tornadoweb#282
1 parent 31e7b78 commit 3d64c89

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

tornado/test/wsgi_test.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,27 @@ class HelloHandler(RequestHandler):
2525
def get(self):
2626
self.write("Hello world!")
2727

28+
class PathQuotingHandler(RequestHandler):
29+
def get(self, path):
30+
self.write(path)
31+
2832
# It would be better to run the wsgiref server implementation in
2933
# another thread instead of using our own WSGIContainer, but this
3034
# fits better in our async testing framework and the wsgiref
3135
# validator should keep us honest
3236
return WSGIContainer(validator(WSGIApplication([
33-
("/", HelloHandler)])))
37+
("/", HelloHandler),
38+
("/path/(.*)", PathQuotingHandler),
39+
])))
3440

3541
def test_simple(self):
3642
response = self.fetch("/")
3743
self.assertEqual(response.body, b("Hello world!"))
3844

45+
def test_path_quoting(self):
46+
response = self.fetch("/path/foo%20bar%C3%A9")
47+
self.assertEqual(response.body, u"foo bar\u00e9".encode("utf-8"))
48+
3949
# This is kind of hacky, but run some of the HTTPServer tests through
4050
# WSGIContainer and WSGIApplication to make sure everything survives
4151
# repeated disassembly and reassembly.

tornado/wsgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def environ(request):
235235
environ = {
236236
"REQUEST_METHOD": request.method,
237237
"SCRIPT_NAME": "",
238-
"PATH_INFO": request.path,
238+
"PATH_INFO": urllib.unquote(request.path),
239239
"QUERY_STRING": request.query,
240240
"REMOTE_ADDR": request.remote_ip,
241241
"SERVER_NAME": host,

0 commit comments

Comments
 (0)