Skip to content

Commit

Permalink
Unquote PATH_INFO in wsgi.
Browse files Browse the repository at this point in the history
Closes #281
Closes #282
  • Loading branch information
bdarnell committed Jun 14, 2011
1 parent 31e7b78 commit 3d64c89
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion tornado/test/wsgi_test.py
Expand Up @@ -25,17 +25,27 @@ class HelloHandler(RequestHandler):
def get(self):
self.write("Hello world!")

class PathQuotingHandler(RequestHandler):
def get(self, path):
self.write(path)

# It would be better to run the wsgiref server implementation in
# another thread instead of using our own WSGIContainer, but this
# fits better in our async testing framework and the wsgiref
# validator should keep us honest
return WSGIContainer(validator(WSGIApplication([
("/", HelloHandler)])))
("/", HelloHandler),
("/path/(.*)", PathQuotingHandler),
])))

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

def test_path_quoting(self):
response = self.fetch("/path/foo%20bar%C3%A9")
self.assertEqual(response.body, u"foo bar\u00e9".encode("utf-8"))

# This is kind of hacky, but run some of the HTTPServer tests through
# WSGIContainer and WSGIApplication to make sure everything survives
# repeated disassembly and reassembly.
Expand Down
2 changes: 1 addition & 1 deletion tornado/wsgi.py
Expand Up @@ -235,7 +235,7 @@ def environ(request):
environ = {
"REQUEST_METHOD": request.method,
"SCRIPT_NAME": "",
"PATH_INFO": request.path,
"PATH_INFO": urllib.unquote(request.path),
"QUERY_STRING": request.query,
"REMOTE_ADDR": request.remote_ip,
"SERVER_NAME": host,
Expand Down

0 comments on commit 3d64c89

Please sign in to comment.