skip multipart/ elements and consider text/plain as body (#13025)

This commit is contained in:
Frédéric Péters 2016-09-02 09:57:50 +02:00
parent a3a89458a7
commit 63852abd34
1 changed files with 7 additions and 3 deletions

View File

@ -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