Fix content disposition reading for python < 3.5
This commit is contained in:
@@ -147,14 +147,14 @@ def parse_email(raw_email, policy=None):
|
|||||||
for part in email_message.walk():
|
for part in email_message.walk():
|
||||||
content_type = part.get_content_type()
|
content_type = part.get_content_type()
|
||||||
part_maintype = part.get_content_maintype()
|
part_maintype = part.get_content_maintype()
|
||||||
content_disposition = part.get_content_disposition()
|
content_disposition = part.get('Content-Disposition', None)
|
||||||
if content_disposition or not part_maintype == "text":
|
if content_disposition or not part_maintype == "text":
|
||||||
content = part.get_payload(decode=True)
|
content = part.get_payload(decode=True)
|
||||||
else:
|
else:
|
||||||
content = decode_content(part)
|
content = decode_content(part)
|
||||||
|
|
||||||
is_inline = content_disposition is None \
|
is_inline = content_disposition is None \
|
||||||
or content_disposition == "inline"
|
or content_disposition.startswith("inline")
|
||||||
if content_type == "text/plain" and is_inline:
|
if content_type == "text/plain" and is_inline:
|
||||||
body['plain'].append(content)
|
body['plain'].append(content)
|
||||||
elif content_type == "text/html" and is_inline:
|
elif content_type == "text/html" and is_inline:
|
||||||
|
|||||||
Reference in New Issue
Block a user