From 391abc944dbafb0ebffc5e7a68e2e35cdb18b0f0 Mon Sep 17 00:00:00 2001 From: nicholasmhughes Date: Tue, 10 May 2022 18:16:33 -0400 Subject: [PATCH] fix uncomment_regex --- salt/states/file.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/states/file.py b/salt/states/file.py index e45b1a14e955..b27907f8b468 100644 --- a/salt/states/file.py +++ b/salt/states/file.py @@ -6062,7 +6062,7 @@ def comment(name, regex, char="#", backup=".bak", ignore_missing=False): # remove (?i)-like flags, ^ and $ unanchor_regex = re.sub(r"^(\(\?[iLmsux]\))?\^?(.*?)\$?$", r"\2", regex) - uncomment_regex = "[^{}]?".format(char) + unanchor_regex + uncomment_regex = "^(?!.*{}).*".format(char) + unanchor_regex comment_regex = char + unanchor_regex # Make sure the pattern appears in the file before continuing