summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorGislene Pereira <gislene01@gmail.com>2015-12-29 17:13:59 -0300
committerGislene Pereira <gislene01@gmail.com>2015-12-29 17:13:59 -0300
commit22ab584f81b598e1aa61ae86b27b08459b589b16 (patch)
tree60891d09a4f343697ac07dd23ea3d54011a970ff /service
parent4f0b8e6b062d54c99e398d43e34ac857ad1c9e3c (diff)
Issue #562 - Capture inline attachments from Content Disposition.
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py2
-rw-r--r--service/test/unit/adapter/mailstore/test_leap_mailstore.py15
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'))