summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py4
-rw-r--r--service/test/integration/test_leap_mailstore.py25
2 files changed, 27 insertions, 2 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py
index 70b53c37..97c95a90 100644
--- a/service/pixelated/adapter/mailstore/leap_mailstore.py
+++ b/service/pixelated/adapter/mailstore/leap_mailstore.py
@@ -166,7 +166,7 @@ class LeapMail(Mail):
def _extract_filename(headers, default_filename='UNNAMED'):
- content_disposition = headers.get('Content-Disposition', '')
+ content_disposition = headers.get('Content-Disposition') or headers.get('content-disposition', '')
filename = _extract_filename_from_name_header_part(content_disposition)
if not filename:
filename = headers.get('Content-Description', '')
@@ -363,7 +363,7 @@ class LeapMailStore(MailStore):
return self._extract_part_map(part_maps)
def _is_attachment(self, part_map, headers):
- disposition = headers.get('Content-Disposition', None)
+ disposition = headers.get('Content-Disposition') or headers.get('content-disposition')
content_type = part_map['ctype']
if 'multipart' in content_type:
diff --git a/service/test/integration/test_leap_mailstore.py b/service/test/integration/test_leap_mailstore.py
index 07ab0b44..383ad6ea 100644
--- a/service/test/integration/test_leap_mailstore.py
+++ b/service/test/integration/test_leap_mailstore.py
@@ -39,6 +39,31 @@ class LeapMailStoreTest(SoledadTestBase):
self.assertEqual(expected_mail_dict, result.as_dict())
@defer.inlineCallbacks
+ def test_get_mail_with_attachment(self):
+ input_mail = MIMEMultipart()
+ input_mail.attach(MIMEText(u'a utf8 message', _charset='utf-8'))
+ attachment = MIMEApplication('pretend to be binary attachment data')
+ attachment.add_header('Content-Disposition', 'attachment', filename='filename.txt')
+ input_mail.attach(attachment)
+
+ mail = yield self.mail_store.add_mail('INBOX', input_mail.as_string())
+ fetched_mail = yield self.mail_store.get_mail(mail.ident, include_body=True)
+ self.assertTrue(fetched_mail.as_dict()['attachments'])
+
+ @defer.inlineCallbacks
+ def test_attachment_name(self):
+ input_mail = MIMEMultipart()
+ input_mail.attach(MIMEText(u'a utf8 message', _charset='utf-8'))
+ attachment = MIMEApplication('pretend to be binary attachment data')
+ attachment.add_header('Content-Disposition', 'attachment', filename='filename.txt')
+ input_mail.attach(attachment)
+
+ mail = yield self.mail_store.add_mail('INBOX', input_mail.as_string())
+ fetched_mail = yield self.mail_store.get_mail(mail.ident, include_body=True)
+ fetched_attachment_name = fetched_mail.as_dict()['attachments'][0]['name']
+ self.assertEqual(fetched_attachment_name, 'filename.txt')
+
+ @defer.inlineCallbacks
def test_round_trip_through_soledad_does_not_modify_content(self):
mail = load_mail_from_file('mbox00000000')
mail_id = yield self._create_mail_in_soledad(mail)