forked from mirror/django-mailbox
Fix text content with text attachment (#170)
* Add tests case for text content with text attachment * Fix parsing text message with text attachment
This commit is contained in:
parent
dfad0f8f9c
commit
7eecb0d41d
2 changed files with 4 additions and 1 deletions
|
|
@ -401,6 +401,7 @@ class TestProcessEmail(EmailMessageTestCase):
|
|||
msg = self.mailbox.process_incoming_message(email_object)
|
||||
|
||||
self.assertEqual(msg.attachments.all().count(), 1)
|
||||
self.assertEqual('Has an attached text document, too!', msg.text)
|
||||
|
||||
def test_message_with_long_content(self):
|
||||
email_object = self._get_email_object(
|
||||
|
|
@ -468,4 +469,4 @@ class TestProcessEmail(EmailMessageTestCase):
|
|||
|
||||
with gzip.open(msg.eml.name, 'rb') as f:
|
||||
self.assertEqual(f.read(),
|
||||
self._get_email_as_text('generic_message.eml'))
|
||||
self._get_email_as_text('generic_message.eml'))
|
||||
|
|
|
|||
|
|
@ -108,6 +108,8 @@ def get_body_from_message(message, maintype, subtype):
|
|||
"""
|
||||
body = six.text_type('')
|
||||
for part in message.walk():
|
||||
if part.get('content-disposition', '').startswith('attachment;'):
|
||||
continue
|
||||
if part.get_content_maintype() == maintype and \
|
||||
part.get_content_subtype() == subtype:
|
||||
charset = part.get_content_charset()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue