#26036: URL dispatcher including forward slashes in parameter capture
-------------------------------------+-------------------------------------
     Reporter:  mriedelumab          |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Core (URLs)          |                  Version:  1.8
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  url forward slash    |             Triage Stage:
  parameter                          |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by knbk):

 * status:  new => closed
 * needs_better_patch:   => 0
 * resolution:   => invalid
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 In your URLconf you use the end-of-line character `$`, so the slash must
 be the last character of the url. Since the original url
 `password/myusername/favicon.ico` does not match, you are redirected to
 the same url with a trailing slash. The capturing group then must be
 anything between `password/` and the last `/`.

 In your CLI example, you omit the `$`, so the `/` does not have to be the
 last character, and the regex matches the original url. The capturing
 group then matches everything up to the last `/`, which is just
 `myusername` in this case.

 If you need to match more than just `\w`, you can define a more inclusive
 character set, i.e.:

 {{{
 url(r'^password/(?P<username>[\w+-]+)/$', views.reset_password,
 name='password'),
 }}}

 I don't see any of the relevant code that has changed in 1.8.x releases,
 so I suspect that's the whole of the issue. If there is something else
 that points at a regression in a 1.8.x. release, please reopen.

--
Ticket URL: <https://code.djangoproject.com/ticket/26036#comment:1>
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/069.3449ba308da115f362471870dfe1364f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to