From 7ded13dafb6a29dcbbbabc32008685db49d42f77 Mon Sep 17 00:00:00 2001 From: Simon Fondrie-Teitler Date: Fri, 29 Sep 2017 12:12:23 -0400 Subject: [bug] Keep content-type when it is set in message headers When content-type was set in the message headers instead of the MIMEPart (e.g. when not using MIMEParts in the message) bitmask would ignore it and add the content as text/plain. This caused problems with Nylas. To fix this, if the message is not Multipart I'm keeping the assumption that everything is going to have the maintype of "text" but copying the subtype from the original message. This also decodes the original message's payload before attaching the old content to the new message to make up for the loss of encoding information. -Resolves: #9064 --- src/leap/bitmask/mail/outgoing/service.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/leap') diff --git a/src/leap/bitmask/mail/outgoing/service.py b/src/leap/bitmask/mail/outgoing/service.py index 86fb63c2..18d266ef 100644 --- a/src/leap/bitmask/mail/outgoing/service.py +++ b/src/leap/bitmask/mail/outgoing/service.py @@ -342,7 +342,8 @@ class OutgoingMail(object): msg = MIMEMultipart() for h, v in origmsg.items(): msg.add_header(h, v) - msg.attach(MIMEText(origmsg.get_payload())) + msg.attach(MIMEText(origmsg.get_payload(decode=True), + origmsg.get_content_subtype())) keymsg = MIMEApplication(from_key.key_data, _subtype='pgp-keys', _encoder=lambda x: x) -- cgit v1.2.3