Opened 7 years ago
Last modified 5 years ago
#28936 closed Bug
simplify_regex should remove redundant escape sequences outside groups — at Initial Version
Description ¶
django.contrib.admindocs.views.simplify_urls should clean up escapes found outside path parameters. Otherwise, broken URLs with backslashes can be generated and displayed.
This is readily apparent with Django 2's path(), which aggresively escapes everything outside a <parameter> specifier, resulting in a urlpattern with backslash-escaped forward slashes:
>>> simplify_regex(r"^(?P<sport_slug>\w+)/athletes/(?P<athlete_slug>\w+)/$") '/<sport_slug>/athletes/<athlete_slug>/' >>> simplify_regex(r"^(?P<sport_slug>\w+)\/athletes\/(?P<athlete_slug>\w+)\/$") '/<sport_slug>\\/athletes\\/<athlete_slug>\\/'
The second example is what path() would generate in urlpatterns.
Note:
See TracTickets
for help on using tickets.