Commit Graph

217 Commits

Author SHA1 Message Date
R David Murray 1b6c724df0 #11686: add missing entries to email __all__ lists.
Original patch by Steffen Daode Nurpmeso
2012-03-16 22:43:05 -04:00
R David Murray 9fd170e2d0 #14062: fix BytesParser handling of linesep for Header objects
This also affected smtplib.SMTP.send_message, which calls BytesParser.
2012-03-14 14:05:03 -04:00
R David Murray 7441a7aedd #14291: if a header has non-ascii unicode, default to CTE using utf-8
In Python2, if a unicode string was assigned as the value of a header,
email would automatically CTE encode it using the UTF8 charset.
This capability was lost in the Python3 translation, and this patch
restores it.

Patch by Ali Ikinci, assisted by R. David Murray.

I also added a fix for the mailbox test that was depending (with a comment
that it was a bad idea to so depend) on non-ASCII causing message_from_string
to raise an error.  It now uses support.patch to induce an error during
message serialization.
2012-03-14 02:59:51 -04:00
R David Murray e5e366c856 #11584: make Header and make_header handle binary unknown-8bit input
Analogous to the decode_header fix, this fix makes Header.append and
make_header correctly handle the unknown-8bit charset introduced by email5.1,
when the input to them is binary strings.  Previous to this fix the
make_header(decode_header(x)) == x invariant was broken in the face of the
unknown-8bit charset.
2011-06-18 12:57:28 -04:00
R David Murray 6bdb1769dc #11584: make decode_header handle Header objects correctly
This updates b21fdfa0019c, which fixed this bug incorrectly.
2011-06-18 12:30:55 -04:00
R David Murray 01581ee0b7 #11492: rewrite header folding algorithm. Less code, more passing tests. 2011-04-18 10:04:34 -04:00
R David Murray a2860e8b51 Improve message.py test coverage to 100%.
coverage.py reports 99% on branch coverage, but that appears to be
a bug or limitation in coverage.py.
2011-04-16 09:20:30 -04:00
R David Murray 80221ed0c0 Merge #11492: fix header truncation on folding when there are runs of split chars.
Not a complete fix for this issue.
2011-04-07 20:56:31 -04:00
R David Murray e1292a25d8 #11492: fix header truncation on folding when there are runs of split chars.
Not a complete fix for this issue.
2011-04-07 20:54:03 -04:00
R David Murray b65df26830 Merge: Improve test coverage of _split_ascii method. 2011-04-07 20:40:01 -04:00
R David Murray 7da4db118e Improve test coverage of _split_ascii method. 2011-04-07 20:37:17 -04:00
R David Murray c5c1472895 #11605: don't use set/get_payload in feedparser; they do conversions.
Really the whole API needs to be gone over to restore the
separation of concerns; but that's what email6 is about.
2011-04-06 08:13:02 -04:00
R David Murray 041015cc70 #11584: Since __getitem__ returns headers, make decode_header handle them.
Why I consider this a bug rather than an API change: the API change was
to Message, which didn't used to return Headers unless you added them
yourself.  Now it does (for 8bit binary header input), so decode_header
needs to be able to handle them.
2011-03-25 15:10:55 -04:00
R David Murray c7d28be62f Merge #11606: improved body_encode algorithm, no longer produces overlong lines 2011-03-24 12:27:23 -04:00
R David Murray b938c8c253 #11606: improved body_encode algorithm, no longer produces overlong lines
Algorithm and initial patch by Michael Henry.
2011-03-24 12:19:26 -04:00
R David Murray 523b41c4b3 Merge #11590: fix quoprimime decode handling of empty strings and line endings. 2011-03-23 15:27:04 -04:00
R David Murray cafd79d904 #11590: fix quoprimime decode handling of empty strings and line endings. 2011-03-23 15:25:55 -04:00
R David Murray 3d9e973abd Merge #11589: add additional tests for the email quoprimime module. 2011-03-23 14:27:18 -04:00
R David Murray ec1b5b88ee #11589: add additional tests for the email quoprimime module.
Patch by Michael Henry.
2011-03-23 14:19:05 -04:00
R David Murray a215023b78 #11243: tests and fixes for handling of 'dirty data' in additional methods 2011-03-16 21:11:23 -04:00
R David Murray 4e4326829f Merge #11401 fix from 3.1. 2011-03-16 18:27:34 -04:00
R David Murray de91276a5c #11401: handle headers with no value. 2011-03-16 18:26:23 -04:00
R David Murray 78099bb153 Merge #9298 fix. 2011-03-16 16:13:07 -04:00
R David Murray 6d94bd470e #9298: restore proper folding of base64 encoded bodies.
Patch by Yves Dorfsman.
2011-03-16 15:52:22 -04:00
R David Murray 56a9d7e3da #11554: reactivate test_email_codecs, and make it pass.
The fix is to charset.py, which was not doing the encoding to the
correct output character set when doing a body_encode for either
the shift-jis or euc-jp charsets.  There's also a fix for handling
a bytes input in encoders.py.

Patch by Michael Henry, comment changes by me.
2011-03-15 12:20:02 -04:00
R David Murray 3a6152f3b3 Fix header encoding of long headers when using euc-jp and shift_jis.
When a header was long enough to need to be split across lines, the
input charset name was used instead of the output charset name in
the encoded words.  This make a difference only for the two charsets
above.
2011-03-14 21:13:03 -04:00
Antoine Pitrou d1b1991fd4 Lib/email/test/data/msg_26.txt had its line endings wrong in the SVN repository.
(they were probably converted right in working copies through an SVN property)
2011-03-05 21:49:50 +01:00
Georg Brandl 49857f8a93 Add updated .hgeol file and fix newlines in the 3.2 branch. 2011-03-05 15:11:35 +01:00
R. David Murray 43b2f457a0 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.
........
2011-02-11 03:13:19 +00:00
R. David Murray 7372a07fd0 #11019: Make BytesGenerator handle Message with None body.
Bug discovery and initial patch by Victor Stinner.
2011-01-26 21:21:32 +00:00
R. David Murray 389af00371 Merged revisions 87873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r87873 | r.david.murray | 2011-01-08 21:35:24 -0500 (Sat, 08 Jan 2011) | 12 lines

  #5871: protect against header injection attacks.

  This makes Header.encode throw a HeaderParseError if it winds up
  formatting a header such that a continuation line has no leading
  whitespace and looks like a header.  Since Header accepts values
  containing newlines and preserves them (and this is by design), without
  this fix any program that took user input (say, a subject in a web form)
  and passed it to the email package as a header was vulnerable to header
  injection attacks.  (As far as we know this has never been exploited.)

  Thanks to Jakub Wilk for reporting this vulnerability.
........
2011-01-09 02:48:04 +00:00
R. David Murray 5b2d9ddf69 #5871: protect against header injection attacks.
This makes Header.encode throw a HeaderParseError if it winds up
formatting a header such that a continuation line has no leading
whitespace and looks like a header.  Since Header accepts values
containing newlines and preserves them (and this is by design), without
this fix any program that took user input (say, a subject in a web form)
and passed it to the email package as a header was vulnerable to header
injection attacks.  (As far as we know this has never been exploited.)

Thanks to Jakub Wilk for reporting this vulnerability.
2011-01-09 02:35:24 +00:00
R. David Murray 9253214fd9 #10686: recode non-ASCII headers to 'unknown-8bit' instead of ?s.
This applies only when generating strings from non-RFC compliant binary
input; it makes the existing recoding behavior more consistent (ie:
now no data is lost when recoding).
2011-01-07 23:25:30 +00:00
R. David Murray 6f0022d84a 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.
2011-01-07 21:57:25 +00:00
R. David Murray f9844c8292 Merged revisions 87750 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r87750 | r.david.murray | 2011-01-04 20:39:32 -0500 (Tue, 04 Jan 2011) | 5 lines

  #10790: make append work when output codec is different from input codec

  There's still a bug here (the encode call shouldn't use the 'errors'
  paramter), but I'll fix that later.
........
2011-01-05 01:47:38 +00:00
R. David Murray 477efb3944 #10790: make append work when output codec is different from input codec
There's still a bug here (the encode call shouldn't use the 'errors'
paramter), but I'll fix that later.
2011-01-05 01:39:32 +00:00
R. David Murray dfd7eb0ba2 #1693546: don't add quotes around RFC 2231 encoded values.
The RFC is bit hard to understand on this point, but the examples
clearly show that parameter values that are encoded according
to its charset/language rules don't have surrounding quotes, and
the ABNF does not allow for quotes.  So when we produce such
encoded values, we no longer add quotes.
2010-12-24 22:36:49 +00:00
R. David Murray 4a62e89728 #1155362: allow hh:mm:ss-uuuu like we allow hh:mm:ss+uuuu in parsedate_tz
Original patch by Thomas Herve.
2010-12-23 20:35:46 +00:00
R. David Murray 27c1914c1b Merged revisions 87415 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r87415 | r.david.murray | 2010-12-21 13:07:59 -0500 (Tue, 21 Dec 2010) | 4 lines

  Fix the change made for issue 1243654.

  Surprisingly, it turns out there was no test that exercised this code path.
........
2010-12-21 18:11:01 +00:00
R. David Murray 73a559d0c9 Fix the change made for issue 1243654.
Surprisingly, it turns out there was no test that exercised this code path.
2010-12-21 18:07:59 +00:00
R. David Murray 63563cdf9d #9286: Fix the rfc822 parser to preserve whitespace in address local part.
Such addresses are not RFC compliant except under the 'obsolete syntax'
rules, but before this fix the whitespace was dropped from the input,
concatenating the pieces.  That breaks one of the principles of the
email package, that of preserving the input as much as possible.
It also denies the application program the opportunity to apply its
own heuristics to interpretation of such non-compliant addresses.

It is possible users of the email package were depending on the local
part always being a single token, so this fix will not be backported.
2010-12-18 18:25:38 +00:00
R. David Murray ccb9d05b6c Merged revisions 87217 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r87217 | r.david.murray | 2010-12-13 18:51:19 -0500 (Mon, 13 Dec 2010) | 5 lines

  #1078919: make add_header automatically do RFC2231 encoding when needed.

  Also document the use of three-tuples if control of the charset
  and language is desired.
........
2010-12-13 23:57:01 +00:00
R. David Murray 7ec754b7da #1078919: make add_header automatically do RFC2231 encoding when needed.
Also document the use of three-tuples if control of the charset
and language is desired.
2010-12-13 23:51:19 +00:00
R. David Murray a0b44b5adb #8989: add 'domain' keyword to make_msgid.
Patch by Adrian von Bidder.
2010-12-02 21:47:19 +00:00
R. David Murray 719a449ba6 Fix TestBytesGeneratorIdempotent tests and a couple bugs they revealed.
The tests that were failing on (some) windows machines, where the
msg_XX.txt files used native \r\n lineseps are now also run on machines
that use \n natively, and conversely the \n tests are run on Windows.
The failing tests revealed one place where linesep needed to be added
to a flatten call in generator.  There was also another that the tests
didn't catch, so I added a test for that case as well.
2010-11-21 16:53:48 +00:00
Ezio Melotti 19f2aeba67 Merged revisions 86596 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r86596 | ezio.melotti | 2010-11-20 21:04:17 +0200 (Sat, 20 Nov 2010) | 1 line

  #9424: Replace deprecated assert* methods in the Python test suite.
........
2010-11-21 01:30:29 +00:00
Ezio Melotti b3aedd4862 #9424: Replace deprecated assert* methods in the Python test suite. 2010-11-20 19:04:17 +00:00
R. David Murray e5db2636f3 Improve TestBytesGeneratorIdempotent using by using linesep.
Also corrects a typo from a previous commit.  Unfortunately
this does *not* fix issue #10134.
2010-11-20 15:10:13 +00:00
Brett Cannon 384917a922 Properly close files used by test_email. 2010-10-29 23:08:36 +00:00
R. David Murray 8451c4b6e0 #1349106: add linesep argument to generator.flatten and header.encode. 2010-10-23 22:19:56 +00:00