mirror of
https://github.com/python/cpython.git
synced 2025-11-09 06:01:05 +00:00
get_payload(): If we get a low-level binascii.Error when base64
decoding the payload, just return it as-is.
This commit is contained in:
parent
3efb651ea3
commit
21191d3e31
1 changed files with 12 additions and 5 deletions
|
|
@ -5,13 +5,14 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import binascii
|
||||||
import warnings
|
import warnings
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
from types import ListType, TupleType, StringType
|
from types import ListType, TupleType, StringType
|
||||||
|
|
||||||
# Intrapackage imports
|
# Intrapackage imports
|
||||||
from email import Errors
|
|
||||||
from email import Utils
|
from email import Utils
|
||||||
|
from email import Errors
|
||||||
from email import Charset
|
from email import Charset
|
||||||
|
|
||||||
SEMISPACE = '; '
|
SEMISPACE = '; '
|
||||||
|
|
@ -169,9 +170,11 @@ class Message:
|
||||||
Content-Transfer-Encoding header. When True and the message is not a
|
Content-Transfer-Encoding header. When True and the message is not a
|
||||||
multipart, the payload will be decoded if this header's value is
|
multipart, the payload will be decoded if this header's value is
|
||||||
`quoted-printable' or `base64'. If some other encoding is used, or
|
`quoted-printable' or `base64'. If some other encoding is used, or
|
||||||
the header is missing, the payload is returned as-is (undecoded). If
|
the header is missing, or if the payload has bogus base64 data, the
|
||||||
the message is a multipart and the decode flag is True, then None is
|
payload is returned as-is (undecoded).
|
||||||
returned.
|
|
||||||
|
If the message is a multipart and the decode flag is True, then None
|
||||||
|
is returned.
|
||||||
"""
|
"""
|
||||||
if i is None:
|
if i is None:
|
||||||
payload = self._payload
|
payload = self._payload
|
||||||
|
|
@ -186,7 +189,11 @@ class Message:
|
||||||
if cte.lower() == 'quoted-printable':
|
if cte.lower() == 'quoted-printable':
|
||||||
return Utils._qdecode(payload)
|
return Utils._qdecode(payload)
|
||||||
elif cte.lower() == 'base64':
|
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
|
# Everything else, including encodings with 8bit or 7bit are returned
|
||||||
# unchanged.
|
# unchanged.
|
||||||
return payload
|
return payload
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue