diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2018-12-04 22:38:04 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2018-12-07 20:13:38 +0000 |
commit | e7b29f53e9928ddb7b467fcf1bdd1bb650668cba (patch) | |
tree | 676b90595ef9c6d3dea6ec08880261152d51f9e1 /tests | |
parent | ea48518c0013695f243ad437561124b67a5bc6c9 (diff) |
add test test_unknown_cte_value
that tests if a message with unknown content-transfer-encoding header,
but otherwise correct ascii encoded payload, is warned about.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/db/utils_test.py | 12 | ||||
-rw-r--r-- | tests/static/mail/malformed-header-CTE-2.eml | 9 |
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/db/utils_test.py b/tests/db/utils_test.py index 160ef453..6656aae5 100644 --- a/tests/db/utils_test.py +++ b/tests/db/utils_test.py @@ -750,3 +750,15 @@ class TestRemoveCte(unittest.TestCase): # We expect no Exceptions but a complaint in the log logmsg = 'INFO:root:Unknown Content-Transfer-Encoding: "7bit;"' self.assertEqual(cm.output, [logmsg]) + + def test_unknown_cte_value(self): + with open('tests/static/mail/malformed-header-CTE-2.eml') as fp: + mail = email.message_from_file(fp) + + with self.assertLogs(level='DEBUG') as cm: # keep logs + utils.remove_cte(mail, as_string=True) + + # We expect no Exceptions but a complaint in the log + logmsg = 'DEBUG:root:failed to interpret Content-Transfer-Encoding: '\ + '"normal"' + self.assertIn(logmsg, cm.output) diff --git a/tests/static/mail/malformed-header-CTE-2.eml b/tests/static/mail/malformed-header-CTE-2.eml new file mode 100644 index 00000000..898cf2ec --- /dev/null +++ b/tests/static/mail/malformed-header-CTE-2.eml @@ -0,0 +1,9 @@ +Subject: malformed Content-Transfer-Encoding v2 +To: lucc@github +From: test@alot +MIME-Version: 1.0; +Content-Type: text/plain; charset=iso-8859-1; +Content-Transfer-Encoding: normal + +This message contains an invalid header value for the "Content-Transfer-Encoding": +issue #1301 |