Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#24700 closed Cleanup/optimization (fixed)

Some documentation examples incorrectly use \w to match against slugs in URLs

Reported by: Baptiste Mispelon Owned by: nobody
Component: Documentation Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

On https://docs.djangoproject.com/en/dev/topics/http/urls/#including-other-urlconfs (found with git grep -IF \\w -- docs/), slugs are matched using \w+, like so:

    url(r'^(?P<page_slug>\w+)-(?P<page_id>\w+)/history/$', views.history),
    url(r'^(?P<page_slug>\w+)-(?P<page_id>\w+)/edit/$', views.edit),
    url(r'^(?P<page_slug>\w+)-(?P<page_id>\w+)/discuss/$', views.discuss),
    url(r'^(?P<page_slug>\w+)-(?P<page_id>\w+)/permissions/$', views.permissions),

This is incorrect, since slugs can also contain dashes (-) so [\w-]+ should be used instead.

Change History (3)

comment:1 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Marcus Pennington <marcuspen@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 269a5db:

Fixed #24700 -- Added dash to slug regex in http docs

comment:3 by Tim Graham <timograham@…>, 9 years ago

In 2a334d79:

[1.8.x] Fixed #24700 -- Added dash to slug regex in http docs

Backport of 269a5dbdd37362e27b2bb3bf3a600ffd5ea2c3bb from master

Note: See TracTickets for help on using tickets.
Back to Top