summaryrefslogtreecommitdiffstats
path: root/Lib/email/errors.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-06-12 13:46:26 (GMT)
committerTal Einat <taleinat+github@gmail.com>2018-06-12 13:46:26 (GMT)
commit63dd1f70c1aa57494802c9b68f9db4918620fc8f (patch)
tree2c64b4539d836a5bee6f58a5e88bedda81d3cc67 /Lib/email/errors.py
parent9e01ef2303c64aba456552156b570af72cac0d91 (diff)
downloadcpython-63dd1f70c1aa57494802c9b68f9db4918620fc8f.zip
cpython-63dd1f70c1aa57494802c9b68f9db4918620fc8f.tar.gz
cpython-63dd1f70c1aa57494802c9b68f9db4918620fc8f.tar.bz2
bpo-27397: Make email module properly handle invalid-length base64 strings (GH-7583) (GH-7665)
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. (cherry picked from commit c3f55be7dd012b7e92901627d0b31c21e983ccb4) Co-authored-by: Tal Einat <taleinat+github@gmail.com>
Diffstat (limited to 'Lib/email/errors.py')
-rw-r--r--Lib/email/errors.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/email/errors.py b/Lib/email/errors.py
index 791239f..d28a680 100644
--- a/Lib/email/errors.py
+++ b/Lib/email/errors.py
@@ -73,6 +73,9 @@ class InvalidBase64PaddingDefect(MessageDefect):
class InvalidBase64CharactersDefect(MessageDefect):
"""base64 encoded sequence had characters not in base64 alphabet"""
+class InvalidBase64LengthDefect(MessageDefect):
+ """base64 encoded sequence had invalid length (1 mod 4)"""
+
# These errors are specific to header parsing.
class HeaderDefect(MessageDefect):