diff options
author | Lucas Hoffmann <lucc@posteo.de> | 2018-10-11 01:22:42 +0200 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2018-12-03 08:28:32 +0000 |
commit | 1d95cf991130df7f4d277ed2f840a397d512146d (patch) | |
tree | fca1b5efc4ff53340777d4a3a7d699f3a283ed87 /tests | |
parent | d5b3aab3ac12e0f627b03aedbbe14c8df0d709b2 (diff) |
Add test for #1301
This adds a test for detecting a malformed content-transfer-encoding
(trailing semi-colon).
It also changes the raised exception to the more appropriate ValueError.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/db/utils_test.py | 7 | ||||
-rw-r--r-- | tests/static/mail/malformed-header-CTE.eml | 10 |
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/db/utils_test.py b/tests/db/utils_test.py index 9fd49d76..fe4a1705 100644 --- a/tests/db/utils_test.py +++ b/tests/db/utils_test.py @@ -741,3 +741,10 @@ class TestRemoveCte(unittest.TestCase): # This should not raise an UnicodeDecodeError. utils.remove_cte(mail, as_string=True) self.assertTrue(True) + + def test_malformed_cte_value(self): + with open('tests/static/mail/malformed-header-CTE.eml') as fp: + mail = email.message_from_file(fp) + with self.assertRaisesRegex(ValueError, + "Unknown Content-Transfer-Encoding"): + utils.remove_cte(mail, as_string=True) diff --git a/tests/static/mail/malformed-header-CTE.eml b/tests/static/mail/malformed-header-CTE.eml new file mode 100644 index 00000000..1c3895c2 --- /dev/null +++ b/tests/static/mail/malformed-header-CTE.eml @@ -0,0 +1,10 @@ +Subject: malformed Content-Transfer-Encoding +To: lucc@github +From: test@alot +MIME-Version: 1.0; +Content-Type: text/plain; charset=iso-8859-1; +Content-Transfer-Encoding: 7bit; + +This message contains a malformed header value for the "Content-Transfer-Encoding": +It should be "7bit", not "7bit;". +issue #1301 |