Skip to content

Commit

Permalink
Fix decoding of non-ascii characters in query strings
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed May 25, 2011
1 parent ca2be3e commit 50c2e49
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions tornado/httpserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import time
import urlparse

from tornado.escape import utf8
from tornado.escape import utf8, native_str
from tornado import httputil
from tornado import ioloop
from tornado import iostream
Expand Down Expand Up @@ -506,7 +506,7 @@ def __init__(self, method, uri, version="HTTP/1.0", headers=None,
self._start_time = time.time()
self._finish_time = None

scheme, netloc, path, query, fragment = urlparse.urlsplit(uri)
scheme, netloc, path, query, fragment = urlparse.urlsplit(native_str(uri))
self.path = path
self.query = query
arguments = parse_qs(query)
Expand Down
14 changes: 13 additions & 1 deletion tornado/test/httpserver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,16 @@ def test_multipart_form(self):
self.assertEqual(u"\u00e1", data["argument"])
self.assertEqual(u"\u00f3", data["filename"])
self.assertEqual(u"\u00fa", data["filebody"])


class EchoHandler(RequestHandler):
def get(self):
self.write(self.request.arguments)

class HTTPServerTest(AsyncHTTPTestCase, LogTrapTestCase):
def get_app(self):
return Application([("/echo", EchoHandler)])

def test_query_string_encoding(self):
response = self.fetch("/echo?foo=%C3%A9")
data = json_decode(response.body)
self.assertEqual(data, {u"foo": [u"\u00e9"]})

0 comments on commit 50c2e49

Please sign in to comment.