summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_email/test_email.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-45001: Make email date parsing more robust against malformed input ↵Miss Islington (bot)2021-08-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-27946) Various date parsing utilities in the email module, such as email.utils.parsedate(), are supposed to gracefully handle invalid input, typically by raising an appropriate exception or by returning None. The internal email._parseaddr._parsedate_tz() helper used by some of these date parsing routines tries to be robust against malformed input, but unfortunately it can still crash ungracefully when a non-empty but whitespace-only input is passed. This manifests as an unexpected IndexError. In practice, this can happen when parsing an email with only a newline inside a ‘Date:’ header, which unfortunately happens occasionally in the real world. Here's a minimal example: $ python Python 3.9.6 (default, Jun 30 2021, 10:22:16) [GCC 11.1.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import email.utils >>> email.utils.parsedate('foo') >>> email.utils.parsedate(' ') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.9/email/_parseaddr.py", line 176, in parsedate t = parsedate_tz(data) File "/usr/lib/python3.9/email/_parseaddr.py", line 50, in parsedate_tz res = _parsedate_tz(data) File "/usr/lib/python3.9/email/_parseaddr.py", line 72, in _parsedate_tz if data[0].endswith(',') or data[0].lower() in _daynames: IndexError: list index out of range The fix is rather straight-forward: guard against empty lists, after splitting on whitespace, but before accessing the first element. (cherry picked from commit 989f6a3800f06b2bd31cfef7c3269a443ad94fac) Co-authored-by: wouter bolsterlee <wouter@bolsterl.ee>
* bpo-27513: email.utils.getaddresses() now handles Header objects (GH-13797) ↵Miss Islington (bot)2021-07-191-0/+5
| | | | | | | | | | | (GH-27242) getaddresses() should be able to handle a Header object if passed one. Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit 89f4c34797de2f0e5045da2b97c1c8cbbb42fbb2) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
* bpo-43651: PEP 597: Fix test_email (GH-25158)Inada Naoki2021-04-051-26/+26
|
* bpo-43125: Fix: return expected type (str), not original value (bytes) in ↵Grégory Starck2021-03-301-2/+1
| | | | email/base64mime.py::body_encode (GH-24476)
* bpo-27321 Fix email.generator.py to not replace a non-existent header. ↵Mark Sapiro2020-10-191-0/+35
| | | | | | | | | | | (GH-18074) This PR replaces #1977. The reason for the replacement is two-fold. The fix itself is different is that if the CTE header doesn't exist in the original message, it is inserted. This is important because the new CTE could be quoted-printable whereas the original is implicit 8bit. Also the tests are different. The test_nonascii_as_string_without_cte test in #1977 doesn't actually test the issue in that it passes without the fix. The test_nonascii_as_string_without_content_type_and_cte test is improved here, and even though it doesn't fail without the fix, it is included for completeness. Automerge-Triggered-By: @warsaw
* bpo-40275: Use new test.support helper submodules in tests (GH-21452)Hai Shi2020-08-041-1/+1
|
* bpo-40275: Adding threading_helper submodule in test.support (GH-20263)Hai Shi2020-05-271-2/+3
|
* bpo-39793: use the same domain on make_msgid tests (#18698)Batuhan Taşkaya2020-04-161-4/+6
| | | | | * bpo-39793: use same domain on make_msgid tests * apply suggestions
* bpo-37764: Fix infinite loop when parsing unstructured email headers. (GH-15239)Ashwin Ramaswami2019-08-311-0/+21
| | | | | | | | | | | | Fixes a case in which email._header_value_parser.get_unstructured hangs the system for some invalid headers. This covers the cases in which the header contains either: - a case without trailing whitespace - an invalid encoded word https://bugs.python.org/issue37764 This fix should also be backported to 3.7 and 3.8 https://bugs.python.org/issue37764
* Fix typos in comments, docs and test names (#15018)Min ho Kim2019-07-301-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | * Fix typos in comments, docs and test names * Update test_pyparse.py account for change in string length * Apply suggestion: splitable -> splittable Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Apply suggestion: splitable -> splittable Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Apply suggestion: Dealloccte -> Deallocate Co-Authored-By: Terry Jan Reedy <tjreedy@udel.edu> * Update posixmodule checksum. * Reverse idlelib changes.
* bpo-34155: Dont parse domains containing @ (GH-13079)jpic2019-07-171-0/+14
| | | | | | | | | | | | | | | | | | | | | | Before: >>> email.message_from_string('From: a@malicious.org@important.com', policy=email.policy.default)['from'].addresses (Address(display_name='', username='a', domain='malicious.org'),) >>> parseaddr('a@malicious.org@important.com') ('', 'a@malicious.org') After: >>> email.message_from_string('From: a@malicious.org@important.com', policy=email.policy.default)['from'].addresses (Address(display_name='', username='', domain=''),) >>> parseaddr('a@malicious.org@important.com') ('', 'a@') https://bugs.python.org/issue34155
* bpo-30835: email: Fix AttributeError when parsing invalid CTE (GH-13598)Abhilash Raj2019-06-041-0/+9
| | | | | | | | | | | | | | | | | | | | * bpo-30835: email: Fix AttributeError when parsing invalid Content-Transfer-Encoding Parsing an email containing a multipart Content-Type, along with a Content-Transfer-Encoding containing an invalid (non-ASCII-decodable) byte will fail. email.feedparser.FeedParser._parsegen() gets the header and attempts to convert it to lowercase before comparing it with the accepted encodings, but as the header contains an invalid byte, it's returned as a Header object rather than a str. Cast the Content-Transfer-Encoding header to a str to avoid this. Found using the AFL fuzzer. Reported-by: Daniel Axtens <dja@axtens.net> Signed-off-by: Andrew Donnellan <andrew@donnellan.id.au> * Add email and NEWS entry for the bugfix.
* bpo-27737: Allow whitespace only headers encoding (#13478)Batuhan Taşkaya2019-05-231-0/+3
|
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-4/+1
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* Merge #28407 Improve test coverage of make_msgid.R David Murray2016-12-181-0/+12
|\
| * #28407 Improve test coverage of make_msgid.R David Murray2016-12-181-0/+12
| | | | | | | | Patch by Dillon Brock.
| * #19003: Only replace \r and/or \n line endings in email.generator.R David Murray2016-09-111-0/+12
| | | | | | | | | | This is a further restoration of backward compatibility, as well as being correct per the RFCs.
* | Merge: #19003: Only replace \r and/or \n line endings in email.generator.R David Murray2016-09-111-0/+12
| |
* | #27364: fix "incorrect" uses of escape character in the stdlib.R David Murray2016-09-081-1/+1
| | | | | | | | | | | | | | And most of the tools. Patch by Emanual Barry, reviewed by me, Serhiy Storchaka, and Martin Panter.
* | Issue #27445: Merge from 3.5Berker Peksag2016-09-081-1/+4
|\ \ | |/
| * Issue #27445: Don't pass str(_charset) to MIMEText.set_payload()Berker Peksag2016-09-081-1/+4
| | | | | | | | Patch by Claude Paroz.
| * Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Martin Panter2016-09-071-2/+2
| |
* | Merge: #22233: Only split headers on \r and/or \n, per email RFCs.R David Murray2016-09-071-2/+4
|\ \ | |/
| * #22233: Only split headers on \r and/or \n, per email RFCs.R David Murray2016-09-071-2/+4
| | | | | | | | Original patch by Martin Panter, new policy fixes by me.
* | #27331: add policy keyword argument to all MIME subclasses.R David Murray2016-09-071-0/+41
| | | | | | | | Patch by Berker Peksag.
* | Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Raymond Hettinger2016-08-301-2/+2
| |
* | Merge ISO-8859 fixes from 3.5Martin Panter2016-08-101-2/+2
|\ \ | |/
| * Correct misspellings of ISO-8859Martin Panter2016-08-101-2/+2
| |
* | Issue #23277: Remove unused imports in tests.Serhiy Storchaka2016-04-241-1/+0
|/
* Issue #6598: Avoid clock wrapping around in test_make_msgid_collisions.Serhiy Storchaka2015-11-101-1/+1
|\ | | | | | | Use time.monotonic instead of time.clock.
| * Issue #6598: Avoid clock wrapping around in test_make_msgid_collisions.Serhiy Storchaka2015-11-101-1/+4
| | | | | | | | Use time.monotonic or time.time instead of time.clock.
* | Issue #25523: Merge "a" to "an" fixes from 3.4 into 3.5Martin Panter2015-11-021-1/+1
|\ \ | |/
| * Issue #25523: Correct "a" article to "an" articleMartin Panter2015-11-021-1/+1
| | | | | | | | | | | | This changes the main documentation, doc strings, source code comments, and a couple error messages in the test suite. In some cases the word was removed or edited some other way to fix the grammar.
* | Issue #6598: Increased time precision and random number range inSerhiy Storchaka2015-05-191-1/+24
|\ \ | |/ | | | | email.utils.make_msgid() to strengthen the uniqueness of the message ID.
| * Issue #6598: Increased time precision and random number range inSerhiy Storchaka2015-05-191-1/+24
| | | | | | | | email.utils.make_msgid() to strengthen the uniqueness of the message ID.
* | #21083: add get_content_disposition method to email.message.R David Murray2015-05-161-0/+11
| | | | | | | | Patch by Abhilash Raj.
* | merge 3.4 (#19996)Benjamin Peterson2015-01-261-0/+6
|\ \ | |/
| * handle headers with no key (closes #19996)Benjamin Peterson2015-01-261-0/+6
| | | | | | | | Patch by Cory Benfield.
* | Issue #16324: _charset parameter of MIMEText now also accepts ↵Berker Peksag2014-09-261-0/+4
|/ | | | | | email.charset.Charset instances. Initial patch by Claude Paroz.
* Decreased memory requirements of new tests added in issue21448.Serhiy Storchaka2014-08-121-1/+2
|
* Issue #21448: Fixed FeedParser feed() to avoid O(N**2) behavior when parsing ↵Serhiy Storchaka2014-08-121-4/+59
| | | | | | long line. Original patch by Raymond Hettinger.
* #21476: Unwrap fp in BytesParser so the file isn't unexpectedly closed.R David Murray2014-06-261-0/+25
| | | | This makes the behavior match that of Parser. Patch by Vajrasky Kok.
* #11558: Better message if attach called on non-multipart.R David Murray2014-03-061-0/+8
| | | | Original patch by Varun Sharma.
* Merge: #14983: always add a line end after a MIME boundary marker.R David Murray2014-02-081-5/+10
|\
| * #14983: always add a line end after a MIME boundary marker.R David Murray2014-02-081-5/+10
| | | | | | | | | | | | | | | | | | This is more RFC compliant (see issue) and fixes a problem with signature verifiers rejecting the part when signed. There is some amount of backward compatibility concern here since it changes the output, but the RFC issue coupled with fixing the problem with signature verifiers seems worth the small risk of breaking code that depends on the current incorrect output.
* | Merge #19772: Do not mutate message when downcoding to 7bit.R David Murray2014-02-081-1/+11
|\ \ | |/
| * #19772: Do not mutate message when downcoding to 7bit.R David Murray2014-02-081-1/+11
| | | | | | | | | | | | | | | | | | This is a bit of an ugly hack because of the way generator pieces together the output message. The deepcopys aren't too expensive, though, because we know it is only called on messages that are not multiparts, and the payload (the thing that could be large) is an immutable object. Test and preliminary work on patch by Vajrasky Kok.
* | Merge: #17369: Improve handling of broken RFC2231 values in get_filename.R David Murray2014-02-071-0/+20
|\ \ | |/
| * #17369: Improve handling of broken RFC2231 values in get_filename.R David Murray2014-02-071-0/+20
| | | | | | | | This fixes a regression relative to python2.
* | #20531: Apply the 3.3 version of the #19063 fix.R David Murray2014-02-071-0/+32
| | | | | | | | | | So passing unicode to set_payload works again (but still doesn't do what you want when the message is serialized).