diff options
author | Tal Einat <taleinat+github@gmail.com> | 2018-06-12 15:46:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-12 15:46:22 +0300 |
commit | c3f55be7dd012b7e92901627d0b31c21e983ccb4 (patch) | |
tree | 86fb2e7e33615aee453d73f27063a4ec345e89fa /Lib/test/test_email/test__header_value_parser.py | |
parent | 5a9820918077a65db90f24733edc8935c3e2130e (diff) | |
download | cpython-git-c3f55be7dd012b7e92901627d0b31c21e983ccb4.tar.gz |
bpo-27397: Make email module properly handle invalid-length base64 strings (#7583)
When attempting to base64-decode a payload of invalid length (1 mod 4),
properly recognize and handle it. The given data will be returned as-is,
i.e. not decoded, along with a new defect, InvalidBase64LengthDefect.
Diffstat (limited to 'Lib/test/test_email/test__header_value_parser.py')
-rw-r--r-- | Lib/test/test_email/test__header_value_parser.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_email/test__header_value_parser.py b/Lib/test/test_email/test__header_value_parser.py index 5cdc4bceca..5036de2ca0 100644 --- a/Lib/test/test_email/test__header_value_parser.py +++ b/Lib/test/test_email/test__header_value_parser.py @@ -347,6 +347,15 @@ class TestParser(TestParserMixin, TestEmailBase): errors.InvalidBase64PaddingDefect], '') + def test_get_unstructured_invalid_base64_length(self): + # bpo-27397: Return the encoded string since there's no way to decode. + self._test_get_x(self._get_unst, + '=?utf-8?b?abcde?=', + 'abcde', + 'abcde', + [errors.InvalidBase64LengthDefect], + '') + def test_get_unstructured_no_whitespace_between_ews(self): self._test_get_x(self._get_unst, '=?utf-8?q?foo?==?utf-8?q?bar?=', |