1
0
Fork 0

fix message.text exception when attachment filename header contains weird characters

Add failing test for bad header character

fix

add comment
This commit is contained in:
Adam Reisinger 2024-04-25 12:22:30 +02:00
parent 376bcff6bf
commit 488c726c2d
4 changed files with 339 additions and 2 deletions

View file

@ -446,3 +446,13 @@ class TestProcessEmail(EmailMessageTestCase):
with gzip.open(msg.eml.name, 'rb') as f:
self.assertEqual(f.read(),
self._get_email_as_text('generic_message.eml'))
def test_message_bad_character_in_attachment_filename(self):
'''
Regression test for handling weird characters in attachment filename headers.
Previously accessing msg.text threw an exception.
'''
message = self._get_email_object('bad_character_attachment.eml')
msg = self.mailbox.process_incoming_message(message)
self.assertIsNotNone(msg.text)