diff options
author | R David Murray <rdmurray@bitdance.com> | 2011-03-23 19:25:55 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2011-03-23 19:25:55 (GMT) |
commit | cafd79d904d19e90af375dbee43668f7dbf733d0 (patch) | |
tree | 68b1da59f56382ff622bf028c93595224a9e4337 /Lib/email/quoprimime.py | |
parent | ec1b5b88ee31ba64d80f7d2e4af721718e450499 (diff) | |
download | cpython-cafd79d904d19e90af375dbee43668f7dbf733d0.zip cpython-cafd79d904d19e90af375dbee43668f7dbf733d0.tar.gz cpython-cafd79d904d19e90af375dbee43668f7dbf733d0.tar.bz2 |
#11590: fix quoprimime decode handling of empty strings and line endings.
Diffstat (limited to 'Lib/email/quoprimime.py')
-rw-r--r-- | Lib/email/quoprimime.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/email/quoprimime.py b/Lib/email/quoprimime.py index 85efc08..7c7711e 100644 --- a/Lib/email/quoprimime.py +++ b/Lib/email/quoprimime.py @@ -135,9 +135,9 @@ def header_encode(header_bytes, charset='iso-8859-1'): charset names the character set to use in the RFC 2046 header. It defaults to iso-8859-1. """ - # Return empty headers unchanged + # Return empty headers as an empty string. if not header_bytes: - return str(header_bytes) + return '' # Iterate over every byte, encoding if necessary. encoded = [] for octet in header_bytes: @@ -268,7 +268,7 @@ def decode(encoded, eol=NL): if i == n: decoded += eol # Special case if original string did not end with eol - if not encoded.endswith(eol) and decoded.endswith(eol): + if encoded[-1] not in '\r\n' and decoded.endswith(eol): decoded = decoded[:-1] return decoded |