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