diff options
author | Barry Warsaw <barry@python.org> | 2003-03-10 16:13:14 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2003-03-10 16:13:14 (GMT) |
commit | 21191d3e31377fff23ea2f71e166f84f3cae1ce8 (patch) | |
tree | ac67df7763e3469ee77d2fe0a11a246e02a31646 /Lib | |
parent | 3efb651ea3e406b77f3dea752f5e691fa01afac5 (diff) | |
download | cpython-21191d3e31377fff23ea2f71e166f84f3cae1ce8.zip cpython-21191d3e31377fff23ea2f71e166f84f3cae1ce8.tar.gz cpython-21191d3e31377fff23ea2f71e166f84f3cae1ce8.tar.bz2 |
get_payload(): If we get a low-level binascii.Error when base64
decoding the payload, just return it as-is.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/email/Message.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Lib/email/Message.py b/Lib/email/Message.py index 16ae120..4c6b3da 100644 --- a/Lib/email/Message.py +++ b/Lib/email/Message.py @@ -5,13 +5,14 @@ """ import re +import binascii import warnings from cStringIO import StringIO from types import ListType, TupleType, StringType # Intrapackage imports -from email import Errors from email import Utils +from email import Errors from email import Charset SEMISPACE = '; ' @@ -169,9 +170,11 @@ class Message: Content-Transfer-Encoding header. When True and the message is not a multipart, the payload will be decoded if this header's value is `quoted-printable' or `base64'. If some other encoding is used, or - the header is missing, the payload is returned as-is (undecoded). If - the message is a multipart and the decode flag is True, then None is - returned. + the header is missing, or if the payload has bogus base64 data, the + payload is returned as-is (undecoded). + + If the message is a multipart and the decode flag is True, then None + is returned. """ if i is None: payload = self._payload @@ -186,7 +189,11 @@ class Message: if cte.lower() == 'quoted-printable': return Utils._qdecode(payload) elif cte.lower() == 'base64': - return Utils._bdecode(payload) + try: + return Utils._bdecode(payload) + except binascii.Error: + # Incorrect padding + return payload # Everything else, including encodings with 8bit or 7bit are returned # unchanged. return payload |