embed RE escape in get_maildropline

This commit is contained in:
2021-12-23 12:10:36 +01:00
parent 002512cf20
commit 6cbdfcecaa

View File

@@ -21,7 +21,7 @@ def qmail_status(user):
# try to find active filter
if re.search(
rf"^{re.escape(get_maildropline(user))}$", qmailfile.read(), re.MULTILINE
rf"^{get_maildropline(user, regex=True)}$", qmailfile.read(), re.MULTILINE
):
# if get_maildropline(user) in qmailfile.read():
return True
@@ -31,7 +31,7 @@ def qmail_status(user):
# filter is deactivated (commented)
if re.search(
rf"^#{re.escape(get_maildropline(user))}$",
rf"^#{get_maildropline(user, regex=True)}$",
qmailfile.read(),
re.MULTILINE,
):
@@ -88,8 +88,11 @@ def get_filterfile(user, name):
return filepath
def get_maildropline(user):
return f"|maildrop {get_filterfile(user, 'FOOBAR')}"
def get_maildropline(user, regex=False):
if regex:
return re.escape(f"|maildrop {get_filterfile(user, 'FOOBAR')}")
else:
return f"|maildrop {get_filterfile(user, 'FOOBAR')}"
@app.route("/")