summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorR. David Murray <rdmurray@bitdance.com>2011-02-11 03:13:19 (GMT)
committerR. David Murray <rdmurray@bitdance.com>2011-02-11 03:13:19 (GMT)
commit43b2f457a069f7f6a97db09385793f85e0b3f698 (patch)
tree201b8bff7a99d7b0988cc2c4e46cd3d873ebcb14 /Lib/email
parentd71c4e9d1351015762a15401332b5d0d34699e02 (diff)
downloadcpython-43b2f457a069f7f6a97db09385793f85e0b3f698.zip
cpython-43b2f457a069f7f6a97db09385793f85e0b3f698.tar.gz
cpython-43b2f457a069f7f6a97db09385793f85e0b3f698.tar.bz2
Merged revisions 87136,87221,87256,87337-87338,87571,87839,88164 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r87136 | r.david.murray | 2010-12-08 17:53:00 -0500 (Wed, 08 Dec 2010) | 6 lines Have script_helper._assert_python strip refcount strings from stderr. This makes the output of the function and those that depend on it independent of whether or not they are being run under a debug build. ........ r87221 | r.david.murray | 2010-12-13 19:55:46 -0500 (Mon, 13 Dec 2010) | 4 lines #10699: fix docstring for tzset: it does not take a parameter Thanks to Garrett Cooper for the fix. ........ r87256 | r.david.murray | 2010-12-14 21:19:14 -0500 (Tue, 14 Dec 2010) | 2 lines #10705: document what the values of debuglevel are and mean. ........ r87337 | r.david.murray | 2010-12-17 11:11:40 -0500 (Fri, 17 Dec 2010) | 2 lines #10559: provide instructions for accessing sys.argv when first mentioned. ........ r87338 | r.david.murray | 2010-12-17 11:29:07 -0500 (Fri, 17 Dec 2010) | 2 lines #10454: clarify the compileall docs and help messages. [compileall.py changes not backported.] ........ r87571 | r.david.murray | 2010-12-29 14:06:48 -0500 (Wed, 29 Dec 2010) | 2 lines Fix same typo in docs. ........ r87839 | r.david.murray | 2011-01-07 16:57:25 -0500 (Fri, 07 Jan 2011) | 9 lines Fix formatting of values with embedded newlines when rfc2047 encoding Before this patch if a value being encoded had an embedded newline, the line following the newline would have no leading whitespace, and the whitespace it did have was encoded into the word. Now the existing whitespace gets turned into a blank, the way it does in other header reformatting, and the _continuation_ws gets added at the beginning of the encoded line. ........ r88164 | r.david.murray | 2011-01-24 14:34:58 -0500 (Mon, 24 Jan 2011) | 12 lines #10960: fix 'stat' links, link to lstat from stat, general tidy of stat doc. Original patch by Michal Nowikowski, with some additions and wording fixes by me. I changed the wording from 'Performs a stat system call' to 'Performs the equivalent of a stat system call', since on Windows there are no stat/lstat system calls involved. I also extended Michal's breakout of the attributes into a list to the other paragraphs, and rearranged the order of the paragraphs in the 'stat' docs to make it flow better and put it in what I think is a more logical/useful order. ........
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/header.py11
-rw-r--r--Lib/email/test/test_email.py14
2 files changed, 22 insertions, 3 deletions
diff --git a/Lib/email/header.py b/Lib/email/header.py
index ce55d61..a391255 100644
--- a/Lib/email/header.py
+++ b/Lib/email/header.py
@@ -304,10 +304,15 @@ class Header:
self._continuation_ws, splitchars)
for string, charset in self._chunks:
lines = string.splitlines()
- for line in lines:
+ formatter.feed(lines[0], charset)
+ for line in lines[1:]:
+ formatter.newline()
+ if charset.header_encoding is not None:
+ formatter.feed(self._continuation_ws, USASCII)
+ line = ' ' + line.lstrip()
formatter.feed(line, charset)
- if len(lines) > 1:
- formatter.newline()
+ if len(lines) > 1:
+ formatter.newline()
formatter.add_transition()
value = str(formatter)
if _embeded_header.search(value):
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
index 5222bab..0f28a9c 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -9,6 +9,7 @@ import base64
import difflib
import unittest
import warnings
+import textwrap
from io import StringIO
from itertools import chain
@@ -959,6 +960,19 @@ List: List-Unsubscribe: <http://lists.sourceforge.net/lists/listinfo/spamassassi
""")
+ def test_long_rfc2047_header_with_embedded_fws(self):
+ h = Header(textwrap.dedent("""\
+ We're going to pretend this header is in a non-ascii character set
+ \tto see if line wrapping with encoded words and embedded
+ folding white space works"""),
+ charset='utf-8',
+ header_name='Test')
+ self.assertEqual(h.encode()+'\n', textwrap.dedent("""\
+ =?utf-8?q?We=27re_going_to_pretend_this_header_is_in_a_non-ascii_chara?=
+ =?utf-8?q?cter_set?=
+ =?utf-8?q?_to_see_if_line_wrapping_with_encoded_words_and_embedded?=
+ =?utf-8?q?_folding_white_space_works?=""")+'\n')
+
# Test mangling of "From " lines in the body of a message