fix some stuff

This commit is contained in:
2020-06-09 01:56:35 +02:00
parent 699e76acba
commit 2f8865cd66
2 changed files with 7 additions and 7 deletions

View File

@@ -60,10 +60,10 @@ def add_header(field, value, milter, idx=-1, pretend=False,
def mod_header(field, value, milter, search=None, pretend=False,
logger=logging.getLogger(__name__)):
"""Change the value of a mail header field."""
if not isinstance(field, re.Pattern):
if isinstance(field, str):
field = re.compile(field, re.IGNORECASE)
if search is not None and not isinstance(search, re.Pattern):
if isinstance(search, str):
search = re.compile(search, re.MULTILINE + re.DOTALL + re.IGNORECASE)
occ = defaultdict(int)
@@ -110,10 +110,10 @@ def mod_header(field, value, milter, search=None, pretend=False,
def del_header(field, milter, value=None, pretend=False,
logger=logging.getLogger(__name__)):
"""Delete a mail header field."""
if not isinstance(field, re.Pattern):
if isinstance(field, str):
field = re.compile(field, re.IGNORECASE)
if value is not None and not isinstance(value, re.Pattern):
if isinstance(value, str):
value = re.compile(value, re.MULTILINE + re.DOTALL + re.IGNORECASE)
idx = -1