mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
remove (?x) modifiers
at the start of the regex there can be modifiers which also have to be removed, see #39188
This commit is contained in:
parent
9d8e72b881
commit
66a25796a4
@ -4107,7 +4107,9 @@ def comment(name, regex, char='#', backup='.bak'):
|
|||||||
if not check_res:
|
if not check_res:
|
||||||
return _error(ret, check_msg)
|
return _error(ret, check_msg)
|
||||||
|
|
||||||
unanchor_regex = regex.lstrip('^').rstrip('$')
|
# remove (?i)-like flags, ^ and $
|
||||||
|
unanchor_regex = re.sub(r'^(\(\?[iLmsux]\))?\^?(.*?)\$?$', r'\2', regex)
|
||||||
|
|
||||||
comment_regex = char + unanchor_regex
|
comment_regex = char + unanchor_regex
|
||||||
|
|
||||||
# Check if the line is already commented
|
# Check if the line is already commented
|
||||||
|
Loading…
Reference in New Issue
Block a user