From 448d974d9646b96806ef07a9ceeceb96e4bac645 Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Thu, 8 Jul 2021 00:19:35 +0100 Subject: [PATCH] Fixed #32499 -- Escaped additional metacharacters in simplify_regex(). --- django/contrib/admindocs/utils.py | 2 +- tests/admin_docs/test_views.py | 43 +++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py index 1dc30a39604..b836d17fd15 100644 --- a/django/contrib/admindocs/utils.py +++ b/django/contrib/admindocs/utils.py @@ -145,7 +145,7 @@ unnamed_group_matcher = _lazy_re_compile(r'\(') def replace_metacharacters(pattern): """Remove unescaped metacharacters from the pattern.""" return re.sub( - r'((?:^|(?\w+)\B/(\w+)?', '//'), + (r'^\A(?P\w+)\Z', '/'), ) for pattern, output in tests: with self.subTest(pattern=pattern):