From 85540da9303287cc13fdce95971a23c9799226f3 Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Wed, 7 Jul 2021 23:26:06 +0100 Subject: [PATCH] Refs #32499 -- Fixed escaped metacharacters in simplify_regex(). --- django/contrib/admindocs/utils.py | 6 +++++- tests/admin_docs/test_views.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py index b3a0526874..1dc30a3960 100644 --- a/django/contrib/admindocs/utils.py +++ b/django/contrib/admindocs/utils.py @@ -144,7 +144,11 @@ unnamed_group_matcher = _lazy_re_compile(r'\(') def replace_metacharacters(pattern): """Remove unescaped metacharacters from the pattern.""" - return pattern.replace('^', '').replace('$', '').replace('?', '') + return re.sub( + r'((?:^|(?