fix illegal chars in headers and monkey-patch python issues 27257, 30988

This commit is contained in:
2020-11-12 21:58:00 +01:00
parent d9f2b515ff
commit 7e33bce6ea
2 changed files with 79 additions and 4 deletions

View File

@@ -45,7 +45,7 @@ def add_header(milter, field, value, pretend=False, update_msg=True,
else:
logger.info(f"add_header: {header[0:70]}")
milter.msg.add_header(field, value)
milter.msg.add_header(field, _replace_illegal_chars(value))
if pretend:
return
@@ -74,10 +74,9 @@ def mod_header(milter, field, value, search=None, pretend=False,
if not field.match(f):
continue
new_v = v
if search is not None:
new_v = search.sub(value, v).strip()
else:
new_v = value.strip()
if new_v == v:
continue
@@ -97,7 +96,8 @@ def mod_header(milter, field, value, search=None, pretend=False,
else:
logger.info(f"mod_header: {header[0:70]}: {new_header[0:70]}")
milter.msg.replace_header(f, new_v, occ=occ[f_lower])
milter.msg.replace_header(
f, _replace_illegal_chars(new_v), occ=occ[f_lower])
if pretend:
continue