From c3f55be7dd012b7e92901627d0b31c21e983ccb4 Mon Sep 17 00:00:00 2001 From: Tal Einat Date: Tue, 12 Jun 2018 15:46:22 +0300 Subject: 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. --- Lib/email/errors.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Lib/email/errors.py') diff --git a/Lib/email/errors.py b/Lib/email/errors.py index 791239fa6a..d28a680010 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): -- cgit v1.2.1