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

Merge remote-tracking branch 'upstream/main' into merge-upstream

# Conflicts:
#	.gitignore
#	management/auth.py
#	management/daemon.py
#	management/mail_log.py
#	management/mailconfig.py
#	management/mfa.py
#	management/ssl_certificates.py
#	management/status_checks.py
#	management/utils.py
#	management/web_update.py
#	setup/mail-postfix.sh
#	setup/migrate.py
#	setup/preflight.sh
#	setup/webmail.sh
#	tests/test_mail.py
#	tools/editconf.py
This commit is contained in:
downtownallday
2024-03-12 07:41:14 -04:00
33 changed files with 582 additions and 571 deletions

View File

@@ -110,7 +110,7 @@ except:
found = set()
buf = ""
with open(filename, "r") as f:
with open(filename, encoding="utf-8") as f:
input_lines = list(f)
cur_section = None
@@ -119,7 +119,7 @@ while len(input_lines) > 0:
# If this configuration file uses folded lines, append any folded lines
# into our input buffer.
if folded_lines and line[0] not in (comment_char, " ", ""):
if folded_lines and line[0] not in {comment_char, " ", ""}:
while len(input_lines) > 0 and input_lines[0][0] in " \t":
line += input_lines.pop(0)
@@ -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*$",
r"(\s*)"
+ "(" + re.escape(comment_char) + r"\s*)?"
+ re.escape(name) + delimiter_re + r"(.*?)\s*$",
line, flags)
if not m: continue
indent, is_comment, existing_val = m.groups()
@@ -206,7 +206,7 @@ if not ini_section or cur_section == ini_section.lower():
if not testing:
# Write out the new file.
with open(filename, "w") as f:
with open(filename, "w", encoding="utf-8") as f:
f.write(buf)
else:
# Just print the new file to stdout.

View File

@@ -47,7 +47,7 @@ for date, ip in accesses:
# Since logs are rotated, store the statistics permanently in a JSON file.
# Load in the stats from an existing file.
if os.path.exists(outfn):
with open(outfn, "r") as f:
with open(outfn, encoding="utf-8") as f:
existing_data = json.load(f)
for date, count in existing_data:
if date not in by_date:
@@ -60,5 +60,5 @@ by_date = sorted(by_date.items())
by_date.pop(-1)
# Write out.
with open(outfn, "w") as f:
with open(outfn, "w", encoding="utf-8") as f:
json.dump(by_date, f, sort_keys=True, indent=True)

View File

@@ -133,7 +133,7 @@ def generate_documentation():
""")
parser = Source.parser()
with open("setup/start.sh", "r") as start_file:
with open("setup/start.sh", "r") as start_file:
for line in start_file:
try:
fn = parser.parse_string(line).filename()