[Python-checkins] cpython (merge 3.2 -> default): Merge #11492: fix header truncation on folding when there are runs of split

r.david.murray python-checkins at python.org
Fri Apr 8 03:01:31 CEST 2011


http://hg.python.org/cpython/rev/5ec2695c9c15
changeset: 69203:5ec2695c9c15
parent: 69200:d48b886dd750
parent: 69202:74ec64dc3538
user: R David Murray <rdmurray at bitdance.com>
date: Thu Apr 07 21:00:33 2011 -0400
summary:
 Merge #11492: fix header truncation on folding when there are runs of split chars.
Not a complete fix for this issue.
files:
 Lib/email/header.py | 7 ++++---
 Lib/test/test_email/test_email.py | 10 ++++++++++
 2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/Lib/email/header.py b/Lib/email/header.py
--- a/Lib/email/header.py
+++ b/Lib/email/header.py
@@ -483,12 +483,13 @@
 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 @@
 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/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
@@ -801,6 +801,16 @@
 ;
 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
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /