diff options
author | R David Murray <rdmurray@bitdance.com> | 2011-04-08 00:56:31 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2011-04-08 00:56:31 (GMT) |
commit | 80221ed0c0f3c73ee13c5d2c64a9b0273933a0ce (patch) | |
tree | 9721fa2a5a177f3a0616ea6528ad21f757ffa21c /Lib/email | |
parent | b65df26830d35f83d01385fddd4d7c537bd4d4d0 (diff) | |
parent | e1292a25d8a063dcc97111cd2b0239dc1aef5aa2 (diff) | |
download | cpython-80221ed0c0f3c73ee13c5d2c64a9b0273933a0ce.zip cpython-80221ed0c0f3c73ee13c5d2c64a9b0273933a0ce.tar.gz cpython-80221ed0c0f3c73ee13c5d2c64a9b0273933a0ce.tar.bz2 |
Merge #11492: fix header truncation on folding when there are runs of split chars.
Not a complete fix for this issue.
Diffstat (limited to 'Lib/email')
-rw-r--r-- | Lib/email/header.py | 7 | ||||
-rw-r--r-- | Lib/email/test/test_email.py | 10 |
2 files changed, 14 insertions, 3 deletions
diff --git a/Lib/email/header.py b/Lib/email/header.py index 2562b30..a0f7c45 100644 --- a/Lib/email/header.py +++ b/Lib/email/header.py @@ -483,12 +483,13 @@ class _ValueFormatter: self._current_line.reset(str(holding)) return elif not nextpart: - # There must be some trailing split characters because we + # There must be some trailing or duplicated split characters + # because we # found a split character but no next part. In this case we # must treat the thing to fit as the part + splitpart because # if splitpart is whitespace it's not allowed to be the only # thing on the line, and if it's not whitespace we must split - # after the syntactic break. In either case, we're done. + # after the syntactic break. holding_prelen = len(holding) holding.push(part + splitpart) if len(holding) + len(self._current_line) <= self._maxlen: @@ -503,7 +504,7 @@ class _ValueFormatter: self._lines.append(str(self._current_line)) holding.reset(save_part) self._current_line.reset(str(holding)) - return + holding.reset() elif not part: # We're leading with a split character. See if the splitpart # and nextpart fits on the current line. diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index 48c3c59..605c1be 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -827,6 +827,16 @@ Subject: the first part of this is short, ; this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;""") + def test_long_header_with_multiple_sequential_split_chars(self): + # Issue 11492 + + eq = self.ndiffAssertEqual + h = Header('This is a long line that has two whitespaces in a row. ' + 'This used to cause truncation of the header when folded') + eq(h.encode(), """\ +This is a long line that has two whitespaces in a row. This used to cause + truncation of the header when folded""") + def test_no_split_long_header(self): eq = self.ndiffAssertEqual hstr = 'References: ' + 'x' * 80 |