From 63852abd34b9dba755795cbf58e3719d491371c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 2 Sep 2016 09:57:50 +0200 Subject: [PATCH] skip multipart/ elements and consider text/plain as body (#13025) --- mail2redmine.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mail2redmine.py b/mail2redmine.py index d915aed..37ba316 100644 --- a/mail2redmine.py +++ b/mail2redmine.py @@ -38,6 +38,11 @@ def parse_header(header_text): def parse_attachment(data): + if data.get('Content-type').startswith('multipart/'): + return None + if data.get('Content-type').startswith('text/plain') and not ( + data.get('Content-Disposition', '').startswith('attachment')): + return None file_data = data.get_payload(decode=True) if not file_data: return None @@ -79,9 +84,8 @@ def create_ticket(mail): if attachment: attachments.append(attachment) elif data.get_content_type() == "text/plain": - new_body = data.get_payload(decode=True) - if new_body: - body = unicode(new_body, data.get_content_charset('utf-8')).encode('utf-8') + body = data.get_payload(decode=True) + body = unicode(body, data.get_content_charset('utf-8')).encode('utf-8') # get project tech manager tech_manager = None