diff options
-rw-r--r-- | service/pixelated/adapter/mailstore/leap_mailstore.py | 2 | ||||
-rw-r--r-- | service/test/unit/adapter/mailstore/test_leap_mailstore.py | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py index 1fce388d..33bb6c74 100644 --- a/service/pixelated/adapter/mailstore/leap_mailstore.py +++ b/service/pixelated/adapter/mailstore/leap_mailstore.py @@ -373,7 +373,7 @@ class LeapMailStore(MailStore): phash = part_map['phash'] if 'Content-Disposition' in headers: disposition = headers['Content-Disposition'] - if 'attachment' in disposition: + if 'attachment' in disposition or 'inline' in disposition: filename = _extract_filename(disposition) encoding = headers.get('Content-Transfer-Encoding', None) result.append(AttachmentInfo(phash, filename, encoding)) diff --git a/service/test/unit/adapter/mailstore/test_leap_mailstore.py b/service/test/unit/adapter/mailstore/test_leap_mailstore.py index a2f2d935..6cc58513 100644 --- a/service/test/unit/adapter/mailstore/test_leap_mailstore.py +++ b/service/test/unit/adapter/mailstore/test_leap_mailstore.py @@ -242,6 +242,21 @@ class TestLeapMailStore(TestCase): self.assertEqual(expected, message.as_dict()['attachments']) @defer.inlineCallbacks + def test_add_mail_with_inline_attachment(self): + input_mail = MIMEMultipart() + input_mail.attach(MIMEText(u'a utf8 message', _charset='utf-8')) + attachment = MIMEApplication('pretend to be an inline attachment') + attachment.add_header('Content-Disposition', 'u\'inline;\n\tfilename=super_nice_photo.jpg') + input_mail.attach(attachment) + mocked_message = self._add_create_mail_mocks_to_soledad(input_mail) + store = LeapMailStore(self.soledad) + + message = yield store.add_mail('INBOX', input_mail.as_string()) + + expected = [{'ident': self._cdoc_phash_from_message(mocked_message, 2), 'name': 'super_nice_photo.jpg', 'encoding': 'base64'}] + self.assertEqual(expected, message.as_dict()['attachments']) + + @defer.inlineCallbacks def test_add_mail_with_nested_attachments(self): input_mail = MIMEMultipart() input_mail.attach(MIMEText(u'a utf8 message', _charset='utf-8')) |