From 9db569e3f5170efd852322d428b9b0282c7bb114 Mon Sep 17 00:00:00 2001 From: Folker Bernitt Date: Wed, 6 Jan 2016 16:38:20 +0100 Subject: Support attachments without name in Content-Disposition header - Issue 557 - along the way also added support for signatures and attached keys --- .../unit/adapter/mailstore/test_leap_mailstore.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'service/test/unit/adapter') diff --git a/service/test/unit/adapter/mailstore/test_leap_mailstore.py b/service/test/unit/adapter/mailstore/test_leap_mailstore.py index 6cc58513..f4fa367f 100644 --- a/service/test/unit/adapter/mailstore/test_leap_mailstore.py +++ b/service/test/unit/adapter/mailstore/test_leap_mailstore.py @@ -292,6 +292,27 @@ class TestLeapMailStore(TestCase): self.assertEqual('batatinha.rtf', attachment_info[0].name) self.assertEqual('receipt.pdf', attachment_info[1].name) + def test_extract_attachment_filename_from_other_headers(self): + input_mail = MIMEMultipart() + input_mail.attach(MIMEText(u'a utf8 message', _charset='utf-8')) + + attachment_without_description = MIMEApplication('pretend to be an attachment from apple mail', _subtype='pgp-keys') + attachment_without_description.add_header('Content-Disposition', 'attachment') + attachment_without_description.add_header('Content-Description', 'Some GPG Key') + + input_mail.attach(attachment_without_description) + + attachment_with_name_in_content_type = MIMEApplication('pretend to be an attachment from thunderbird', _subtype='pgp-signature; name="signature.asc"') + attachment_with_name_in_content_type.add_header('Content-Disposition', 'inline') + input_mail.attach(attachment_with_name_in_content_type) + + message = self._add_create_mail_mocks_to_soledad(input_mail) + store = LeapMailStore(self.soledad) + attachment_info = store._extract_attachment_info_from(message) + + self.assertEqual('Some GPG Key', attachment_info[0].name) + self.assertEqual('signature.asc', attachment_info[1].name) + @defer.inlineCallbacks def test_add_mail_with_special_chars(self): input_mail = MIMEText(u'a utf8 message', _charset='utf-8') -- cgit v1.2.3