Ticket #13260: t13260-patch.diff
File t13260-patch.diff, 3.3 KB (added by , 14 years ago) |
---|
-
django/core/urlresolvers.py
15 15 from django.utils.datastructures import MultiValueDict 16 16 from django.utils.encoding import iri_to_uri, force_unicode, smart_str 17 17 from django.utils.functional import memoize 18 from django.utils.http import urlquote 18 19 from django.utils.importlib import import_module 19 20 from django.utils.regex_helper import normalize 20 21 from django.utils.thread_support import currentThread … … 274 275 if args: 275 276 if len(args) != len(params): 276 277 continue 277 unicode_args = [ force_unicode(val) for val in args]278 unicode_args = [urlquote(force_unicode(val)) for val in args] 278 279 candidate = result % dict(zip(params, unicode_args)) 279 280 else: 280 281 if set(kwargs.keys()) != set(params): 281 282 continue 282 unicode_kwargs = dict([(k, force_unicode(v)) for (k, v) in kwargs.items()])283 unicode_kwargs = dict([(k, urlquote(force_unicode(v))) for (k, v) in kwargs.items()]) 283 284 candidate = result % unicode_kwargs 284 285 if re.search(u'^%s' % pattern, candidate, re.UNICODE): 285 286 return candidate -
tests/regressiontests/urlpatterns_reverse/tests.py
67 67 ('product', '/product/chocolate+($2.00)/', [], {'price': '2.00', 'product': 'chocolate'}), 68 68 ('headlines', '/headlines/2007.5.21/', [], dict(year=2007, month=5, day=21)), 69 69 ('windows', r'/windows_path/C:%5CDocuments%20and%20Settings%5Cspam/', [], dict(drive_name='C', path=r'Documents and Settings\spam')), 70 ('special', r'/special_chars/+%5C$*/', [r'+\$*'], {}), 70 ('special', r'/special_chars/%2B%5C%24%2A/', [r'+\$*'], {}), 71 ('special', r'/special_chars/some%20resource/', [r'some resource'], {}), 72 ('special', r'/special_chars/10%25%20complete/', [r'10% complete'], {}), 73 ('special', r'/special_chars/some%20resource/', [], {'chars': r'some resource'}), 74 ('special', r'/special_chars/10%25%20complete/', [], {'chars': r'10% complete'}), 71 75 ('special', NoReverseMatch, [''], {}), 72 76 ('mixed', '/john/0/', [], {'name': 'john'}), 73 77 ('repeats', '/repeats/a/', [], {}), -
tests/regressiontests/urlpatterns_reverse/urls.py
35 35 name="headlines"), 36 36 url(r'^windows_path/(?P<drive_name>[A-Z]):\\(?P<path>.+)/$', empty_view, 37 37 name="windows"), 38 url(r'^special_chars/( .+)/$', empty_view, name="special"),38 url(r'^special_chars/(?P<chars>.+)/$', empty_view, name="special"), 39 39 url(r'^(?P<name>.+)/\d+/$', empty_view, name="mixed"), 40 40 url(r'^repeats/a{1,2}/$', empty_view, name="repeats"), 41 41 url(r'^repeats/a{2,4}/$', empty_view, name="repeats2"),