Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

add unicode URLSpec support #89

Open
shuge opened this Issue May 13, 2010 · 3 comments

Comments

Projects
None yet
2 participants

shuge commented May 13, 2010

Please add unicode URLSpec support.

Patch:

diff --git a/tornado/web.py b/tornado/web.py
index e51948a..cd9a6a4 100644
--- a/tornado/web.py
+++ b/tornado/web.py
@@ -1368,7 +1368,7 @@ class URLSpec(object):
         """
         if not pattern.endswith('$'):
             pattern += '$'
-        self.regex = re.compile(pattern)
+        self.regex = re.compile(pattern, re.UNICODE)
         self.handler_class = handler_class
         self.kwargs = kwargs
         self.name = name
Owner

bdarnell commented May 31, 2010

Does that work? I think there's more work to be done to support non-ascii paths than just redefining the regex character classes. For example, it is my understanding that browsers may send non-ascii paths as percent-encoded utf-8, and tornado does not currently make any attempt to decode them.

shuge commented May 31, 2010

I'm not sure it works well.

I'm deprecated normal name/Unicode String as key/argument

/obj_type/name

I'm use uuid instead,

/obj_type/uuid 

@hellais hellais referenced this issue in hellais/cyclone Jan 29, 2013

@fiorix fiorix Merge pull request #89 from jonoberheide/master
make _remote_ip a property
bda2b6b
Owner

bdarnell commented Jul 16, 2014

From recent discussion on the mailing list: The rules for decoding these urls correctly are complicated and are given in RFC 3987: http://tools.ietf.org/html/rfc3987#section-3.2. We need an implementation of this algorithm and a way for applications to opt in to it (since it would be slow and it is common practice even for non-english sites to restrict the routing-critical part of their url paths to ascii).

@bdarnell bdarnell added the web label Jul 16, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment