From a057080bad3de3b134f7d1827865de898f1098c0 Mon Sep 17 00:00:00 2001 From: Martijn van de Streek Date: Mon, 3 May 2021 23:56:05 +0200 Subject: [PATCH] Fix removing of Content-Type header from transport headers (#16) The fourth argument to `re.sub` is `count`, but `re.I` (a flag) was passed instead. Because if this, messages with a lower-case "content-type" header would never have their content-type header removed, leading to parse errors. By explicity naming the parameter (`flags=`) to re.sub, the match actually becomes case-insensitive. --- outlookmsgfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/outlookmsgfile.py b/outlookmsgfile.py index a0fded5..73c83fb 100644 --- a/outlookmsgfile.py +++ b/outlookmsgfile.py @@ -51,7 +51,7 @@ def load_message_stream(entry, is_top_level, doc): # way is just the plain-text portion of the email and whatever # Content-Type header was in the original is not valid for # reconstructing it this way. - headers = re.sub("Content-Type: .*(\n\s.*)*\n", "", headers, re.I) + headers = re.sub("Content-Type: .*(\n\s.*)*\n", "", headers, flags=re.I) # Parse them. headers = email.parser.HeaderParser(policy=email.policy.default)\