aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/email/message.py
Commit message (Collapse)AuthorAge
* gh-98188: Fix EmailMessage.get_payload to decode data when CTE value has ↵RanKKI2025-01-05
| | | | | | | | | | | extra text (#127547) Up to this point message handling has been very strict with regards to content encoding values: mixed case was accepted, but trailing blanks or other text would cause decoding failure, even if the first token was a valid encoding. By Postel's Rule we should go ahead and decode as long as we can recognize that first token. We have not thought of any security or backward compatibility concerns with this fix. This fix does introduce a new technique/pattern to the Message code: we look to see if the header has a 'cte' attribute, and if so we use that. This effectively promotes the header API exposed by HeaderRegistry to an API that any header parser "should" support. This seems like a reasonable thing to do. It is not, however, a requirement, as the string value of the header is still used if there is no cte attribute. The full fix (ignore any trailing blanks or blank-separated trailing text) applies only to the non-compat32 API. compat32 is only fixed to the extent that it now ignores trailing spaces. Note that the HeaderRegistry parsing still records a HeaderDefect if there is extra text. Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* gh-126133: Only use start year in PSF copyright, remove end years (#126236)Hugo van Kemenade2024-11-12
|
* Remove almost all unpaired backticks in docstrings (#119231)Geoffrey Thomas2024-05-22
| | | | | | | | | | | | | | | | | | As reported in #117847 and #115366, an unpaired backtick in a docstring tends to confuse e.g. Sphinx running on subclasses of standard library objects, and the typographic style of using a backtick as an opening quote is no longer in favor. Convert almost all uses of the form The variable `foo' should do xyz to The variable 'foo' should do xyz and also fix up miscellaneous other unpaired backticks (extraneous / missing characters). No functional change is intended here other than in human-readable docstrings.
* gh-80361: Fix TypeError in email.Message.get_payload() (GH-117994)Serhiy Storchaka2024-04-17
| | | | | It was raised when the charset is rfc2231 encoded, e.g.: Content-Type: text/plain; charset*=ansi-x3.4-1968''utf-8
* gh-76511: Fix email.Message.as_string() for non-ASCII message with ASCII ↵Serhiy Storchaka2024-03-05
| | | | charset (GH-116125)
* gh-94606: Fix error when message with Unicode surrogate not surrogateescaped ↵Sidney Markowitz2023-12-11
| | | | | string (GH-94641) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-102498 Clean up unused variables and imports in the email module (#102482)JosephSBoyle2023-04-24
| | | | | | | | | | | | | | | | | | | | | * Clean up unused variables and imports in the email module * Remove extra newline char * Remove superflous dict+unpacking syntax * Remove unused 'msg' var * Clean up unused variables and imports in the email module * Remove extra newline char * Remove superflous dict+unpacking syntax * Remove unused 'msg' var --------- Co-authored-by: Barry Warsaw <barry@python.org>
* gh-100792: Make `email.message.Message.__contains__` twice as fast (#100793)Nikita Sobolev2023-01-07
|
* gh-91217: deprecate uu (GH-92009)Brett Cannon2022-04-27
| | | Automerge-Triggered-By: GH:brettcannon
* bpo-42892: fix email multipart attribute error (GH-26903)andrei kulakov2021-07-30
|
* bpo-44395: Fix MIMEPart.as_string to pass unixfrom properly (GH-26685)Dong-hee Na2021-06-21
|
* Typo fix - "mesasge" should be "message" (GH-22498)Hansraj Das2020-10-02
| | | * Correct at 2 places in email module
* bpo-33972: Fix EmailMessage.iter_attachments raising AttributeError. (GH-14119)Abhilash Raj2019-06-25
| | | | | | | * bpo-33972: Fix EmailMessage.iter_attachments raising AttributeError. When certain malformed messages have content-type set to 'mulitpart/*' but still have a single part body, iter_attachments can raise AttributeError. This patch fixes it by returning a None value instead when the body is single part.
* #20476: Deal with the message_factory circular import differently.R David Murray2016-09-10
| | | | | | | It turns out we can't depend on email.message getting imported every place message_factory is needed, so to avoid a circular import we need to special case Policy.message_factory=None in the parser instead of using monkey patching. I had a feeling that was a bad idea when I did it.
* #20476: add a message_factory policy attribute to email.R David Murray2016-09-09
|
* #24277: The new email API is no longer provisional.R David Murray2016-09-07
| | | | | | | This is a wholesale reorganization and editing of the email documentation to make the new API the standard one, and the old API the 'legacy' one. The default is still the compat32 policy, for backward compatibility. We will change that eventually.
* Merge: 27988: Make sure iter_attachments does not mutate the payload list.R David Murray2016-09-07
|\
| * 27988: Make sure iter_attachments does not mutate the payload list.R David Murray2016-09-07
| |
* | Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Raymond Hettinger2016-08-30
|/
* Issue #27125: Fix various errors like “will [be] inherited”Martin Panter2016-05-29
|
* #21083: add get_content_disposition method to email.message.R David Murray2015-05-16
| | | | Patch by Abhilash Raj.
* Issue #23181: More "codepoint" -> "code point".Serhiy Storchaka2015-01-18
|\
| * Issue #23181: More "codepoint" -> "code point".Serhiy Storchaka2015-01-18
| |
* | Merge: #21091: make is_attachment a method.R David Murray2014-09-20
|\|
| * #21091: make is_attachment a method.R David Murray2014-09-20
|/ | | | | | Since EmailMessage is a provisional API we can fix API bugs in a maintenance release, but I used a trick suggested by Serhiy to maintain backward compatibility with 3.4.0/1.
* #21079: is_attachment now looks only at the value, ignoring parameters.R David Murray2014-09-20
|
* #20976: remove unneeded quopri import in email.utils.R David Murray2014-03-23
|
* #11558: Better message if attach called on non-multipart.R David Murray2014-03-06
| | | | Original patch by Varun Sharma.
* Merge: #19063: the unicode-in-set_payload problem isn't getting fixed in 3.4.R David Murray2014-02-07
|\
| * #19063: the unicode-in-set_payload problem isn't getting fixed in 3.4.R David Murray2014-02-07
| |
| * #19063: partially fix set_payload handling of non-ASCII string input.R David Murray2013-12-11
| | | | | | | | | | | | This is a backward compatible partial fix, the complete fix requires raising an error instead of accepting the invalid input, so the real fix is only suitable for 3.4.
* | #20531: Apply the 3.3 version of the #19063 fix.R David Murray2014-02-07
| | | | | | | | | | So passing unicode to set_payload works again (but still doesn't do what you want when the message is serialized).
* | #20531: Revert e20f98a8ed71, the 3.4 version of the #19063 fix.R David Murray2014-02-07
| |
* | #19063: fix set_payload handling of non-ASCII string input.R David Murray2013-12-11
| | | | | | | | | | This version of the fix raises an error instead of accepting the invalid input (ie: if a non-ASCII string is used but no charset is specified).
* | Merge #19485: clarify get_param example.R David Murray2013-11-03
|\|
| * #19485: clarify get_param example.R David Murray2013-11-03
| | | | | | | | Patch by Vajrasky Kok.
* | #18891: Complete new provisional email API.R David Murray2013-10-16
| | | | | | | | | | | | | | | | | | | | | | | | This adds EmailMessage and, MIMEPart subclasses of Message with new API methods, and a ContentManager class used by the new methods. Also a new policy setting, content_manager. Patch was reviewed by Stephen J. Turnbull and Serhiy Storchaka, and reflects their feedback. I will ideally add some examples of using the new API to the documentation before the final release.
* | Merge #18324: set_payload now correctly handles binary input.R David Murray2013-08-21
|\|
| * #18324: set_payload now correctly handles binary input.R David Murray2013-08-21
| | | | | | | | | | | | | | | | | | | | | | This also backs out the previous fixes for for #14360, #1717, and #16564. Those bugs were actually caused by the fact that set_payload didn't decode to str, thus rendering the model inconsistent. This fix does mean the data processed by the encoder functions goes through an extra encode/decode cycle, but it means the model is always consistent. Future API updates will provide a better way to encode payloads, which will bypass this minor de-optimization. Tests by Vajrasky Kok.
* | #18600: add policy to add_string, and as_bytes and __bytes__ methods.R David Murray2013-08-09
|/ | | | | | | This was triggered by wanting to make the doctest in email.policy.rst pass; as_bytes and __bytes__ are clearly useful now that we have BytesGenerator. Also updated the Message docs to document the policy keyword that was added in 3.3.
* Merge: Update out of date docstring.R David Murray2012-06-17
|\
| * Update out of date docstring.R David Murray2012-06-17
| |
* | #10839: raise an error on add of duplicate unique headers in new email policiesR David Murray2012-05-29
| | | | | | | | | | | | | | | | | | | | | | This feature was supposed to be part of the initial email6 checkin, but it got lost in my big refactoring. In this patch I'm not providing an easy way to turn off the errors, but they only happen when a header is added programmatically, and it is almost never the right thing to do to allow the duplicate to be added. An application that needs to add duplicates of unique headers can create a policy subclass to allow it.
* | #1672568: email now registers defects for base64 payload format errors.R David Murray2012-05-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Which also means that it is now producing *something* for any base64 payload, which is what leads to the couple of older test changes in test_email. This is a slightly backward incompatible behavior change, but the new behavior is so much more useful than the old (you can now *reliably* detect errors, and any program that was detecting errors by sniffing for a base64 return from get_payload(decode=True) and then doing its own error-recovery decode will just get the error-recovery decode right away). So this seems to me to be worth the small risk inherent in this behavior change. This patch also refactors the defect tests into a separate test file, since they are no longer just parser tests.
* | #14731: refactor email policy framework.R David Murray2012-05-25
|/ | | | | | | | | | | | | | | | | This patch primarily does two things: (1) it adds some internal-interface methods to Policy that allow for Policy to control the parsing and folding of headers in such a way that we can construct a backward compatibility policy that is 100% compatible with the 3.2 API, while allowing a new policy to implement the email6 API. (2) it adds that backward compatibility policy and refactors the test suite so that the only differences between the 3.2 test_email.py file and the 3.3 test_email.py file is some small changes in test framework and the addition of tests for bugs fixed that apply to the 3.2 API. There are some additional teaks, such as moving just the code needed for the compatibility policy into _policybase, so that the library code can import only _policybase. That way the new code that will be added for email6 will only get imported when a non-compatibility policy is imported.
* #11243: tests and fixes for handling of 'dirty data' in additional methodsR David Murray2011-03-16
|
* Merge #11555 as_string doc fix from 3.1.R David Murray2011-03-15
|\
| * #11555: update doc for 3.x change to as_string mangle_from default.R David Murray2011-03-15
| |
| * Merged revisions 87217 via svnmerge fromR. David Murray2010-12-13
| | | | | | | | | | | | | | | | | | | | | | | | | | 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. ........
| * Merged revisions 85130 via svnmerge fromR. David Murray2010-12-06
| | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r85130 | r.david.murray | 2010-09-30 22:08:02 -0400 (Thu, 30 Sep 2010) | 2 lines Fix a couple spelling errors in comments and delete redundant __len__ def. ........