1
0
mirror of https://github.com/django/django.git synced 2025-10-25 06:36:07 +00:00

Fixed #32499 -- Escaped additional metacharacters in simplify_regex().

This commit is contained in:
Nick Pope
2021-07-08 00:19:35 +01:00
committed by Mariusz Felisiak
parent 85540da930
commit 448d974d96
2 changed files with 44 additions and 1 deletions

View File

@@ -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'((?:^|(?<!\\))(?:\\\\)*)(\\?)([?^$])',
r'((?:^|(?<!\\))(?:\\\\)*)(\\?)([?*+^$]|\\[bBAZ])',
lambda m: m[1] + m[3] if m[2] else m[1],
pattern,
)