also consider Content-ID when marking attachment as inline (#126)

Handle MIME attachments with Content-ID as inline by default.

Treat MIME attachments that have a *Content-ID* but no explicit *Content-Disposition*
header as inline, matching the behavior of many email clients.
This commit is contained in:
Leo Antunes
2018-10-11 23:29:00 +02:00
committed by Mike Edmunds
parent 4028eda583
commit 64f7d31d14
4 changed files with 62 additions and 1 deletions

View File

@@ -291,7 +291,8 @@ class Attachment(object):
self.content = attachment.as_string().encode(self.encoding)
self.mimetype = attachment.get_content_type()
if get_content_disposition(attachment) == 'inline':
content_disposition = get_content_disposition(attachment)
if content_disposition == 'inline' or (not content_disposition and 'Content-ID' in attachment):
self.inline = True
self.content_id = attachment["Content-ID"] # probably including the <...>
if self.content_id is not None: