Opened 17 years ago
Closed 17 years ago
#6729 closed (duplicate)
reverse() and {% url %} don't work with slightly-more-advanced regexes
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | url dispatcher reverse regex | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This works fine:
# urls.py urlpatterns = patters('ads.admanager.view', (r'^ad/(?P<id>\d+).html$', 'ad'), ) # somewhere else (e.g. python manage.py shell) from django.core.urlresolvers import reverse url = reverse('ads.admanager.views.ad', kwargs={'id': 123}) # ad/123.html
Note that the regex used also matches e.g. ad/123xhtml , or any other character because of the "." that is not escaped.
This doesn't work:
# urls.py urlpatterns = patters('ads.admanager.view', (r'^ad/(?P<id>\d+)\.html$', 'ad'), # <-- see the escape ( \. ) ) # somewhere else (e.g. python manage.py shell) from django.core.urlresolvers import reverse url = reverse('ads.admanager.views.ad', kwargs={'id': 123}) # ad/123\.html or ad/123%5C.html
Expected: ad/123.html
Got: ad/123\.html
And, yes, I used the SVN version ;-)
Change History (4)
comment:1 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 17 years ago
Status: | assigned → new |
---|
comment:3 by , 17 years ago
Owner: | changed from | to
---|
comment:4 by , 17 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Duplicate of #2977, which I'm slowly working on fixing.