Replace 0-bytes and line breaks, pymilter does not like them

This commit is contained in:
2020-02-28 19:28:20 +01:00
parent cdc3b72220
commit 3b6cebb79c

View File

@@ -210,7 +210,8 @@ class HeaderMilter(Milter.Base):
for name, hdr, index, occurrence in modified:
value = hdr[name]
encoded_value = hdr.as_string().split(": ")[1].rstrip()
# remove illegal characters, pymilter does not like them
encoded_value = hdr.as_string().replace("\r", "").replace("\n", "").replace("\x00", "").split(":", 1)[1].strip()
mod_header = "{}: {}".format(name, value)
if rule.action == "add":
if rule.log: