mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Refs #32499 -- Fixed escaped metacharacters in simplify_regex().
This commit is contained in:
committed by
Mariusz Felisiak
parent
9f7809ece3
commit
85540da930
@@ -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'((?:^|(?<!\\))(?:\\\\)*)(\\?)([?^$])',
|
||||
lambda m: m[1] + m[3] if m[2] else m[1],
|
||||
pattern,
|
||||
)
|
||||
|
||||
|
||||
def replace_named_groups(pattern):
|
||||
|
||||
Reference in New Issue
Block a user