embed RE escape in get_maildropline
This commit is contained in:
@@ -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,7 +88,10 @@ def get_filterfile(user, name):
|
||||
return filepath
|
||||
|
||||
|
||||
def get_maildropline(user):
|
||||
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')}"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user