mirror of
https://github.com/django/daphne.git
synced 2025-04-21 17:22:03 +03:00
Fixed #93: Unicode regex patterns not working on http.request path
This commit is contained in:
parent
afa46cfe0f
commit
6884e7d1e8
|
@ -81,6 +81,16 @@ class Router(object):
|
|||
]
|
||||
return routing
|
||||
|
||||
@classmethod
|
||||
def normalise_re_arg(cls, value):
|
||||
"""
|
||||
Normalises regular expression patterns and string inputs to Unicode.
|
||||
"""
|
||||
if isinstance(value, six.binary_type):
|
||||
return value.decode("ascii")
|
||||
else:
|
||||
return value
|
||||
|
||||
|
||||
class Route(object):
|
||||
"""
|
||||
|
@ -103,7 +113,7 @@ class Route(object):
|
|||
self.consumer = consumer
|
||||
# Compile filter regexes up front
|
||||
self.filters = {
|
||||
name: re.compile(value)
|
||||
name: re.compile(Router.normalise_re_arg(value))
|
||||
for name, value in kwargs.items()
|
||||
}
|
||||
# Check filters don't use positional groups
|
||||
|
@ -130,7 +140,7 @@ class Route(object):
|
|||
for name, value in self.filters.items():
|
||||
if name not in message:
|
||||
return None
|
||||
match = re.match(value, message[name])
|
||||
match = value.match(Router.normalise_re_arg(message[name]))
|
||||
# Any match failure means we pass
|
||||
if match:
|
||||
call_args.update(match.groupdict())
|
||||
|
|
Loading…
Reference in New Issue
Block a user