email_mirror: Handle encoded attachment filenames.

This commit is contained in:
Mateusz Mandera
2020-01-30 15:37:33 +01:00
committed by Tim Abbott
parent c44d9f9b1b
commit 785a7ec9e7
2 changed files with 40 additions and 1 deletions

View File

@@ -238,7 +238,11 @@ def extract_and_upload_attachments(message: message.Message, realm: Realm) -> st
attachment_links = []
for part in message.walk():
content_type = part.get_content_type()
filename = part.get_filename()
encoded_filename = part.get_filename()
if not encoded_filename:
continue
filename = handle_header_content(encoded_filename)
if filename:
attachment = part.get_payload(decode=True)
if isinstance(attachment, bytes):