1
0
Fork 1
mirror of https://github.com/coddingtonbear/django-mailbox.git synced 2026-07-10 06:48:19 +02:00

Fix parsing text message with text attachment

This commit is contained in:
Adam Dobrawy 2018-02-07 21:19:23 +01:00
parent 4100f2ea62
commit a673b17fb3
2 changed files with 3 additions and 1 deletions

View file

@ -401,7 +401,7 @@ class TestProcessEmail(EmailMessageTestCase):
msg = self.mailbox.process_incoming_message(email_object) msg = self.mailbox.process_incoming_message(email_object)
self.assertEqual(msg.attachments.all().count(), 1) self.assertEqual(msg.attachments.all().count(), 1)
self.assertNotIn('This is an attachment.', msg.text) self.assertEqual('Has an attached text document, too!', msg.text)
def test_message_with_long_content(self): def test_message_with_long_content(self):
email_object = self._get_email_object( email_object = self._get_email_object(

View file

@ -108,6 +108,8 @@ def get_body_from_message(message, maintype, subtype):
""" """
body = six.text_type('') body = six.text_type('')
for part in message.walk(): for part in message.walk():
if part.get('content-disposition', '').startswith('attachment;'):
continue
if part.get_content_maintype() == maintype and \ if part.get_content_maintype() == maintype and \
part.get_content_subtype() == subtype: part.get_content_subtype() == subtype:
charset = part.get_content_charset() charset = part.get_content_charset()