From 5a1e173771891b5263f8c16fd222f79a3625189d Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Mon, 4 Oct 2021 23:01:43 +0200 Subject: [PATCH] fix encoding of text and html parts --- pyquarantine/modify.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyquarantine/modify.py b/pyquarantine/modify.py index da613a4..070a7dc 100644 --- a/pyquarantine/modify.py +++ b/pyquarantine/modify.py @@ -268,7 +268,9 @@ class AddDisclaimer: content = f"{text_content}{text_template}" text_body.set_content( - content.encode(), maintype="text", subtype="plain") + content.encode(errors="replace"), + maintype="text", + subtype="plain") text_body.set_param("charset", "UTF-8", header="Content-Type") del text_body["MIME-Version"] @@ -291,7 +293,9 @@ class AddDisclaimer: body.append(html_template) html_body.set_content( - str(soup).encode(), maintype="text", subtype="html") + str(soup).encode(errors="replace"), + maintype="text", + subtype="html") html_body.set_param("charset", "UTF-8", header="Content-Type") del html_body["MIME-Version"]