]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Unquote PATH_INFO in wsgi.
authorBen Darnell <ben@bendarnell.com>
Tue, 14 Jun 2011 21:38:42 +0000 (14:38 -0700)
committerBen Darnell <ben@bendarnell.com>
Tue, 14 Jun 2011 21:38:42 +0000 (14:38 -0700)
Closes #281
Closes #282

tornado/test/wsgi_test.py
tornado/wsgi.py

index edca7c51030e83237dc37ce28591b95fd3b8c024..c7894cca06212a37f505ece2226adc554fed0492 100644 (file)
@@ -25,17 +25,27 @@ class WSGIApplicationTest(AsyncHTTPTestCase, LogTrapTestCase):
             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.
index ab87a4ceaa2f01860a0b8457957e77e8686186cb..8b6177f7fd32912a555ba8bdf2e2c5c6e0f94534 100644 (file)
@@ -235,7 +235,7 @@ class WSGIContainer(object):
         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,