1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2026-03-12 17:07:23 +01:00

Fix invalid escape sequences

This commit is contained in:
downtownallday
2024-03-05 08:56:39 -05:00
parent 38ad0d3cd6
commit da2d88e4f4
2 changed files with 12 additions and 12 deletions

View File

@@ -33,7 +33,7 @@
# lines while the lines start with whitespace, e.g.:
#
# NAME VAL
# UE
# UE
import sys, re
@@ -147,9 +147,9 @@ while len(input_lines) > 0:
name, val = (settings[i].name, settings[i].val)
flags = re.S | (re.I if case_insensitive_names else 0)
m = re.match(
"(\s*)"
+ "(" + re.escape(comment_char) + "\s*)?"
+ re.escape(name) + delimiter_re + "(.*?)\s*$",
"(\\s*)"
+ "(" + re.escape(comment_char) + "\\s*)?"
+ re.escape(name) + delimiter_re + "(.*?)\\s*$",
line, flags)
if not m: continue
indent, is_comment, existing_val = m.groups()
@@ -170,7 +170,7 @@ while len(input_lines) > 0:
buf += line
found.add(i)
break
# comment-out the existing line (also comment any folded lines)
if is_comment is None:
if val or not erase_setting or erase_setting_via_comment:
@@ -178,23 +178,23 @@ while len(input_lines) > 0:
else:
# the line is already commented, pass it through
buf += line
# if this option already is set don't add the setting again,
# or if we're clearing the setting with -e, don't add it
if (i in found) or (not val and erase_setting):
break
# add the new setting
buf += indent + name + delimiter + val + "\n"
# note that we've applied this option
found.add(i)
break
else:
# If did not match any setting names, pass this line through.
buf += line
# Put any settings we didn't see at the end of the file,
# except settings being cleared.
if not ini_section or cur_section == ini_section.lower():