Opened 5 years ago

Closed 5 years ago

Last modified 5 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 Changed 5 years ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:2 Changed 5 years ago by Marcus Pennington <marcuspen@…>

Resolution: fixed
Status: newclosed

In 269a5db:

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

comment:3 Changed 5 years ago by Tim Graham <timograham@…>

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