cpython: d9a779be9736 (original) (raw)
Mercurial > cpython
changeset 68877:d9a779be9736
Merge #11590: fix quoprimime decode handling of empty strings and line endings. [#11590]
R David Murray rdmurray@bitdance.com | |
---|---|
date | Wed, 23 Mar 2011 15:37:26 -0400 |
parents | d8dd7ab6039d(current diff)df613f7b726a(diff) |
children | 09b34be885ac |
files | Lib/test/test_email/test_email.py |
diffstat | 2 files changed, 18 insertions(+), 3 deletions(-)[+] [-] Lib/email/quoprimime.py 6 Lib/test/test_email/test_email.py 15 |
line wrap: on
line diff
--- a/Lib/email/quoprimime.py +++ b/Lib/email/quoprimime.py @@ -135,9 +135,9 @@ def header_encode(header_bytes, charset= charset names the character set to use in the RFC 2046 header. It defaults to iso-8859-1. """
return str(header_bytes)[](#l1.10)
return ''[](#l1.11)
encoded = [] Iterate over every byte, encoding if necessary. 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
--- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -3351,6 +3351,9 @@ class TestQuopri(unittest.TestCase): encoded_header = quoprimime.header_encode(header, charset) self.assertEqual(encoded_header, expected_encoded_header)
+ def test_header_encode_one_word(self): self._test_header_encode(b'hello', '=?iso-8859-1?q?hello?=') @@ -3407,6 +3410,15 @@ class TestQuopri(unittest.TestCase): def test_decode_one_line_lf(self): self._test_decode('hello\n', 'hello\n')
+ def test_decode_one_line_one_word(self): self._test_decode('hello\r\nworld', 'hello\nworld') @@ -3416,6 +3428,9 @@ class TestQuopri(unittest.TestCase): 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')[](#l2.34)
+ def test_decode_one_long_line(self): self._test_decode('Spam' * 250, 'Spam' * 250)