[Python-checkins] cpython (merge 3.2 -> default): Merge #11590: fix quoprimime decode handling of empty strings and line endings. (original) (raw)
r.david.murray python-checkins at python.org
Wed Mar 23 20:37:45 CET 2011
- Previous message: [Python-checkins] cpython (merge 3.1 -> 3.2): Merge #11590: fix quoprimime decode handling of empty strings and line endings.
- Next message: [Python-checkins] r88791 - peps/trunk/pep-0398.txt
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
http://hg.python.org/cpython/rev/d9a779be9736 changeset: 68877:d9a779be9736 parent: 68874:d8dd7ab6039d parent: 68876:df613f7b726a user: R David Murray <rdmurray at bitdance.com> date: Wed Mar 23 15:37:26 2011 -0400 summary: Merge #11590: fix quoprimime decode handling of empty strings and line endings.
files: Lib/email/quoprimime.py | 6 +++--- Lib/test/test_email/test_email.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/Lib/email/quoprimime.py b/Lib/email/quoprimime.py --- a/Lib/email/quoprimime.py +++ b/Lib/email/quoprimime.py @@ -135,9 +135,9 @@ charset names the character set to use in the RFC 2046 header. It defaults to iso-8859-1. """
Return empty headers unchanged
if not header_bytes: Return empty headers as an empty string.
return str(header_bytes)
return ''
encoded = [] for octet in header_bytes: @@ -268,7 +268,7 @@ if i == n: decoded += eol Iterate over every byte, encoding if necessary.
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
diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -3351,6 +3351,9 @@ encoded_header = quoprimime.header_encode(header, charset) self.assertEqual(encoded_header, expected_encoded_header)
- def test_header_encode_null(self):
self._test_header_encode(b'', '')
def test_header_encode_one_word(self): self._test_header_encode(b'hello', '=?iso-8859-1?q?hello?=')
@@ -3407,6 +3410,15 @@ def test_decode_one_line_lf(self): self._test_decode('hello\n', 'hello\n')
- def test_decode_one_line_cr(self):
self._test_decode('hello\r', 'hello\n')
- def test_decode_one_line_nl(self):
self._test_decode('hello\n', 'helloX', eol='X')
- def test_decode_one_line_crnl(self):
self._test_decode('hello\r\n', 'helloX', eol='X')
def test_decode_one_line_one_word(self): self._test_decode('hello\r\nworld', 'hello\nworld')
@@ -3416,6 +3428,9 @@ def test_decode_two_lines(self): self._test_decode('hello\r\nworld\r\n', 'hello\nworld\n')
- def test_decode_two_lines_eol(self):
self._test_decode('hello\r\nworld\r\n', 'helloXworldX', eol='X')
def test_decode_one_long_line(self): self._test_decode('Spam' * 250, 'Spam' * 250)
-- Repository URL: http://hg.python.org/cpython
- Previous message: [Python-checkins] cpython (merge 3.1 -> 3.2): Merge #11590: fix quoprimime decode handling of empty strings and line endings.
- Next message: [Python-checkins] r88791 - peps/trunk/pep-0398.txt
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]