#26036: URL dispatcher including forward slashes in parameter capture
-----------------------------+-----------------------------------------
Reporter: mriedelumab | Owner: nobody
Type: Bug | Status: new
Component: Core (URLs) | Version: 1.8
Severity: Normal | Keywords: url forward slash parameter
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+-----------------------------------------
Given the following URL object:
{{{
url(r'^password/(?P<username>\S+)/$', views.reset_password,
name='password'),
}}}
and the following URL:
{{{
password/myusername/favicon.ico/
}}}
Django seems to be capturing {{{username}}} as
{{{myusername/favicon.ico}}} instead of {{{myusername}}}.
When tested in Python's CLI, the parameter capture works properly:
{{{
>>> url = re.compile(r'^password/(?P<username>\S+)/', re.U)
>>> match = url.match('password/myusername/favicon.ico')
>>> match.group('username')
'myusername'
>>> url = re.compile(r'^password/(?P<username>\S+)/', re.L)
>>> match = url.match('password/myusername/favicon.ico')
>>> match.group('username')
'myusername'
}}}
I would expect if the regexp was the issue, I would see
{{{mysuername/favicon.ico}}} in the Python output, also.
I'm using Python 2.7.5 on RHEL 7 with a Virtual Environment for Django
1.8.8. This also happens in 1.8.7. No changes were made to this
application's {{{url.py}}} file since July, and this issue only popped up
since updating to Django 1.8.7 from an earlier version of Django 1.8 (not
sure which minor version).
For now, I'm using a {{{\w+}}} regular expression instead of a {{{\S+}}} -
but that's only a temporary fix. Sometimes I do need to match on special
characters other than underscore (e.g., dash, plus sign, etc.)
--
Ticket URL: <https://code.djangoproject.com/ticket/26036>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/054.3c18abae38a45163d0606338f0090c4e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.