Permalink
Browse files

Fixed #6831 -- Reverse URL resolver now replaces backslashes correctl…

…y. Thanks, Bastian Kleineidam

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7660 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 02bbd9a commit e073861332addfa7fd5577083dfaa6ab1c64ae6b @adrianholovaty adrianholovaty committed Jun 16, 2008
Showing with 2 additions and 1 deletion.
  1. +1 −1 django/core/urlresolvers.py
  2. +1 −0 tests/regressiontests/urlpatterns_reverse/tests.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."
@@ -17,6 +17,7 @@
('^hardcoded/$', 'hardcoded/', [], {}),
('^hardcoded/$', 'hardcoded/', ['any arg'], {}),
('^hardcoded/$', 'hardcoded/', [], {'kwarg': 'foo'}),
+ ('^hardcoded/doc\\.pdf$', 'hardcoded/doc.pdf', [], {}),
('^people/(?P<state>\w\w)/(?P<name>\w+)/$', 'people/il/adrian/', [], {'state': 'il', 'name': 'adrian'}),
('^people/(?P<state>\w\w)/(?P<name>\d)/$', NoReverseMatch, [], {'state': 'il', 'name': 'adrian'}),
('^people/(?P<state>\w\w)/(?P<name>\w+)/$', NoReverseMatch, [], {'state': 'il'}),

0 comments on commit e073861

Please sign in to comment.