From e073861332addfa7fd5577083dfaa6ab1c64ae6b Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 16 Jun 2008 04:16:21 +0000 Subject: [PATCH] Fixed #6831 -- Reverse URL resolver now replaces backslashes correctly. Thanks, Bastian Kleineidam git-svn-id: http://code.djangoproject.com/svn/django/trunk@7660 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/urlresolvers.py | 2 +- tests/regressiontests/urlpatterns_reverse/tests.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py index 2ef3d6f169..2ad63bfc7d 100644 --- a/django/core/urlresolvers.py +++ b/django/core/urlresolvers.py @@ -86,7 +86,7 @@ def reverse_helper(regex, *args, **kwargs): """ # TODO: Handle nested parenthesis in the following regex. result = re.sub(r'\(([^)]+)\)', MatchChecker(args, kwargs), regex.pattern) - return result.replace('^', '').replace('$', '') + return result.replace('^', '').replace('$', '').replace('\\', '') class MatchChecker(object): "Class used in reverse RegexURLPattern lookup." diff --git a/tests/regressiontests/urlpatterns_reverse/tests.py b/tests/regressiontests/urlpatterns_reverse/tests.py index 8f571ac66c..610c3f7bc7 100644 --- a/tests/regressiontests/urlpatterns_reverse/tests.py +++ b/tests/regressiontests/urlpatterns_reverse/tests.py @@ -17,6 +17,7 @@ test_data = ( ('^hardcoded/$', 'hardcoded/', [], {}), ('^hardcoded/$', 'hardcoded/', ['any arg'], {}), ('^hardcoded/$', 'hardcoded/', [], {'kwarg': 'foo'}), + ('^hardcoded/doc\\.pdf$', 'hardcoded/doc.pdf', [], {}), ('^people/(?P\w\w)/(?P\w+)/$', 'people/il/adrian/', [], {'state': 'il', 'name': 'adrian'}), ('^people/(?P\w\w)/(?P\d)/$', NoReverseMatch, [], {'state': 'il', 'name': 'adrian'}), ('^people/(?P\w\w)/(?P\w+)/$', NoReverseMatch, [], {'state': 'il'}),