267 Commits

Author SHA1 Message Date
Martin v. Löwis
80bdb4841c Revert r52798, r52803, r52824, r54342, as they don't fix
security issues.
2008-03-02 17:15:58 +00:00
Barry Warsaw
c3506024d8 SF patch #1556895; Typo in encoding name in email package.
Patch supplied by Guillaume Rousse.
2007-03-13 18:16:52 +00:00
Barry Warsaw
8752f7116a Fix the tests to work with Python 2.1, which email 2.5 must do. 2006-07-26 03:55:09 +00:00
Barry Warsaw
2bfcf5d1f1 Back port r50693 and r50754 from the trunk (and 2.4 branch):
decode_rfc2231(): Be more robust against buggy RFC 2231 encodings.
Specifically, instead of raising a ValueError when there is a single
tick in the parameter, simply return that the entire string unquoted, with
None for both the charset and the language.  Also, if there are more than 2
ticks in the parameter, interpret the first three parts as the standard RFC
2231 parts, then the rest of the parts as the encoded string.

More RFC 2231 improvements for the email 4.0 package.  As Mark Sapiro
rightly points out there are really two types of continued headers
defined in this RFC (i.e. "encoded" parameters with the form
"name*0*=" and unencoded parameters with the form "name*0="), but we
were were handling them both the same way and that isn't correct.

This patch should be much more RFC compliant in that only encoded
params are %-decoded and the charset/language information is only
extract if there are any encoded params in the segments.  If there are
no encoded params then the RFC says that there will be no
charset/language parts.

Note however that this will change the return value for
Message.get_param() in some cases.  For example, whereas before if you
had all unencoded param continuations you would have still gotten a
3-tuple back from this method (with charset and language == None), you
will now get just a string. I don't believe this is a backward
incompatible change though because the documentation for this method
already indicates that either return value is possible and that you
must do an isinstance(val, tuple) check to discriminate between the
two.  (Yeah that API kind of sucks but we can't change /that/ without
breaking code.)

Test cases, some documentation updates, and a NEWS item accompany this
patch.

Original fewer-than-3-parts fix by Tokio Kikuchi.

Resolves SF bug # 1218081.

Also, bump the package version number to 2.5.8 for release.
2006-07-25 13:06:56 +00:00
Barry Warsaw
e3e785180b Back port from 2.4 branch:
Patch #1464708 from William McVey: fixed handling of nested comments in mail
addresses.  E.g.

"Foo ((Foo Bar)) <foo@example.com>"

Fixes for both rfc822.py and email package.
2006-05-01 03:21:25 +00:00
Barry Warsaw
dc74e34e24 Resolve SF bug 1409403: email.Message should supress warning from uu.decode.
However, the patch in that tracker item is elaborated such that the newly
included unit test pass on Python 2.1 through 2.5.  Note that Python 2.1's
uu.decode() does not have a 'quiet' argument, so we have to be sneaky.

Will port to email 3.0 (although without the backward compatible sneakiness).
2006-02-09 04:03:22 +00:00
Barry Warsaw
f5853f7592 Patches to address SF bugs 1409538 (Japanese codecs in CODEC_MAP) and 1409455
(.set_payload() gives bad .get_payload() results).  Specific changes include:

Simplfy the default CODEC_MAP in Charset.py to not include the Japanese and
Korean codecs.  The names of the codecs are different depending on whether
you're using Python 2.4 and 2.5, which include the codecs by default, or
earlier Python's which provide the codecs under different names as a third
party library.  Now, we attempt to discover which (if either) is available and
populate the CODEC_MAP as appropriate.

Message.set_charset(): When the message does not already have a
Content-Transfer-Encoding header, instead of just adding the header, we also
encode the body as defined by the assigned Charset.  As before, if the
body_encoding is callable, we just call that.  If not, then we add a call to
body_encode() before setting the header.  This way, we guarantee that a
message's text payload is always encoded properly.

Remove the payload encoding code from Generator._handle_text().  With the
above patch, this would cause the body to be doubly encoded.  Doing this in
the Message class is better than only doing it in the Generator.

Added some new tests to ensure everything works correctly.  Also changed the
way the test_email_codecs.py tests get added (using the same lookup code that
the CODEC_MAP adjustments use).

This resolves both issues for email 2.5/Python 2.3.  I will patch forward to
email 3.0 for both Python 2.4 and 2.5.
2006-02-08 13:33:20 +00:00
Barry Warsaw
784fccf810 Resolves SF bug #1423972. 2006-02-04 23:48:22 +00:00
Barry Warsaw
08bc84c8da parsedate_tz(): Return a 1 in the tm_yday field so that the value is
acceptable to Python 2.4's time.strftime().  This fix mirrors the behavior in
email 3.0.  That field is documented as being "not useable" so it might as
well not be buggy too <wink>.

Add a test for this behavior and update a few tests that were expecting a 0 in
this field.  After committing I will run the entire Python 2.3 test suite to
ensure this doesn't break any Python tests.
2006-02-03 04:41:24 +00:00
Barry Warsaw
4e71930f41 SF bug #1403349 solution for email 2.5; some MUAs use the 'file' parameter
name in the Content-Distribution header, so Message.get_filename() should fall
back to using that.  Will port both to email 3.0 and Python 2.5 trunk.

Also, bump the email package version to 2.5.7 for eventual release.  Of
course, add a test case too.

XXX Need to update the documentation.
2006-01-17 04:34:54 +00:00
Barry Warsaw
712d474d3c get_filename(), get_content_charset(): It's possible that the charset named in
an RFC 2231-style header could be bogus or unknown to Python.  In that case,
we return the the text part of the parameter undecoded.  However, in
get_content_charset(), if that is not ascii, then it is an illegal charset and
so we return failobj.

Test cases and a version bump are included.

Committing this to the Python 2.3 branch because I need to generate an email
2.5.6 release that contains these patches.  I will port these fixes to Python
2.4 and 2.5 for email 3.x.
2005-04-29 12:12:02 +00:00
Barry Warsaw
3497155a03 get_boundary(): Fix for SF bug #1060941. RFC 2046 says boundaries may begin
-- but not end -- with whitespace.
2004-11-06 00:14:05 +00:00
Barry Warsaw
8bd9db292d test_boundary_with_leading_space(): Test case for SF bug #1060941. RFC 2046
says boundaries may begin -- but not end -- with whitespace.
2004-11-06 00:13:46 +00:00
Barry Warsaw
c5a6b23719 __getitem__(): Fix docstring, SF 979924. 2004-09-28 04:55:34 +00:00
Barry Warsaw
8dcec1381e Test cases and fixes for bugs described in patch #873418: email/Message.py:
del_param fails when specifying a header.

I'll port this to Python 2.4 shortly.
2004-08-16 15:31:43 +00:00
Barry Warsaw
6d7c1db510 Added a sample message for the test for SF bug # 846938. I'm naming this
msg_40.txt because msg_3[6-9].txt are already used in email3/py2.4 and I'm
going to forward port this test.
2004-05-13 23:14:31 +00:00
Barry Warsaw
0a2ab8293d test_boundary_in_non_multipart(): Added a test for SF bug # 846938. 2004-05-13 23:13:24 +00:00
Barry Warsaw
36d0f15a0b _parsebody(): Do not create subparts unless the container has a main type of
'multipart' and the boundary is defined.  This fixes SF bug # 846938, and
several recent email-sig bugs where something like a text/html message also
had a boundary parameter.  This would later crash the Generator, which only
consulted the Content-Type to decide how to generate the message (and it would
expect just a string, but find a list there instead).
2004-05-13 23:12:33 +00:00
Barry Warsaw
8392386770 Waugh! we need to bump the email package to 2.5.5 for Python 2.3.4. 2004-05-13 22:53:25 +00:00
Barry Warsaw
4fc2a79d0b test_mime_attachments_in_constructor(): New test to check for SF bug # 884030. 2004-05-09 18:00:56 +00:00
Barry Warsaw
98ef3006f6 SF patch # 884030 by Amit Aronovitch; fixes the _subpart argument to match
documented semantics.
2004-05-09 18:00:02 +00:00
Barry Warsaw
717501e9ae __init__(): The docstring was incorrect regarding how header wrapping
gets done when maxheaderlen <> 0.  The header really gets wrapped via
the email.Header.Header class, which has a more sophisticated
algorithm than just splitting on semi-colons.
2003-11-19 02:19:43 +00:00
Walter Dörwald
4958f2741a Backport checkin:
Fix a bunch of typos in documentation, docstrings and comments.
(From SF patch #810751)
2003-10-20 14:34:48 +00:00
Barry Warsaw
90fc2aca00 test_get_param_with_semis_in_quotes(): Test case for SF bug #794466.
Backport candidate.
2003-09-03 04:22:00 +00:00
Barry Warsaw
b1919b7ff5 A fix for parsing parameters when there are semicolons inside the
quotes.  Fixes SF bug #794466, with the essential patch provided by
Stuart D. Gathman.  Specifically,

_parseparam(), _get_params_preserve(): Use the parsing function that
takes quotes into account, as given (essentially) in the bug report's
test program.
2003-09-03 04:21:29 +00:00