From 91144643f35c09d147e76101a2e5944021581109 Mon Sep 17 00:00:00 2001 From: Thomas Oettli Date: Fri, 12 Aug 2022 15:09:30 +0200 Subject: [PATCH] fix html code in text body when html part is injected --- pyquarantine/base.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyquarantine/base.py b/pyquarantine/base.py index ae2447f..60c781c 100644 --- a/pyquarantine/base.py +++ b/pyquarantine/base.py @@ -162,8 +162,9 @@ class MilterMessage(MIMEPart): def inject_body_part(part, content, subtype="plain"): parts = [] text_body = None + text_content = None if subtype == "html": - text_body = part.get_body(preferencelist=("plain")) + text_body, text_content = part.get_body_content("plain") for p in part.iter_parts(): if text_body and p == text_body: @@ -173,8 +174,8 @@ def inject_body_part(part, content, subtype="plain"): boundary = part.get_boundary() p_subtype = part.get_content_subtype() part.clear_content() - if text_body: - part.set_content(content) + if text_content != None: + part.set_content(text_content) part.add_alternative(content, subtype=subtype) else: part.set_content(content, subtype=subtype)