summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2011-03-23 19:37:26 (GMT)
committerR David Murray <rdmurray@bitdance.com>2011-03-23 19:37:26 (GMT)
commit5839b9635cd582a5a2660605a48bddafab44aa06 (patch)
treee5ef72dc91632ad969f80a41c8aeb644b43a8dd8 /Lib/email
parent6ab79d9d5bed43e6e2d6b1b27ab319c02fa1716a (diff)
parent523b41c4b3fe79455fc9d1762056ca3e83972aa1 (diff)
downloadcpython-5839b9635cd582a5a2660605a48bddafab44aa06.zip
cpython-5839b9635cd582a5a2660605a48bddafab44aa06.tar.gz
cpython-5839b9635cd582a5a2660605a48bddafab44aa06.tar.bz2
Merge #11590: fix quoprimime decode handling of empty strings and line endings.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/quoprimime.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/email/quoprimime.py b/Lib/email/quoprimime.py
index 168dfff..bffad4e 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