mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #8726 -- When doing reverse URL resolving, make sure we're consistently
dealing with unicode strings throughout by promoting up from UTF-8 as necessary. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8777 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -228,12 +228,14 @@ class RegexURLResolver(object):
|
||||
if args:
|
||||
if len(args) != len(params):
|
||||
continue
|
||||
candidate = result % dict(zip(params, args))
|
||||
unicode_args = [force_unicode(val) for val in args]
|
||||
candidate = result % dict(zip(params, unicode_args))
|
||||
else:
|
||||
if set(kwargs.keys()) != set(params):
|
||||
continue
|
||||
candidate = result % kwargs
|
||||
if re.search('^%s' % pattern, candidate, re.UNICODE):
|
||||
unicode_kwargs = dict([(k, force_unicode(v)) for (k, v) in kwargs.items()])
|
||||
candidate = result % unicode_kwargs
|
||||
if re.search(u'^%s' % pattern, candidate, re.UNICODE):
|
||||
return candidate
|
||||
raise NoReverseMatch("Reverse for '%s' with arguments '%s' and keyword "
|
||||
"arguments '%s' not found." % (lookup_view, args, kwargs))
|
||||
|
||||
Reference in New Issue
Block a user