summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_email
Commit message (Collapse)AuthorAgeFilesLines
* bpo-38708: email: Fix a potential IndexError when parsing Message-ID (GH-17504)Abhilash Raj2019-12-091-0/+6
| | | | Fix a potential IndexError when passing an empty value to the message-id parser. Instead, HeaderParseError should be raised.
* bpo-38698: Add a new InvalidMessageID token to email header parser. (GH-17503)Abhilash Raj2019-12-091-3/+37
| | | | This adds a new InvalidMessageID token to the email header parser which can be used to represent invalid message-id headers in the parse tree.
* bpo-38698: Prevent UnboundLocalError to pop up in parse_message_id (GH-17277)Claudiu Popa2019-12-051-0/+6
| | | | | | | | | parse_message_id() was improperly using a token defined inside an exception handler, which was raising `UnboundLocalError` on parsing an invalid value. https://bugs.python.org/issue38698
* bpo-38332: Catch KeyError from unknown cte in encoded-word. (GH-16503)Andrei Troie2019-10-052-0/+14
| | | KeyError should cause a failure in parsing the encoded word and should be caught and raised as a _InvalidEWError instead.
* bpo-37764: Fix infinite loop when parsing unstructured email headers. (GH-15239)Ashwin Ramaswami2019-08-312-0/+37
| | | | | | | | | | | | 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
* bpo-37482: Fix email address name with encoded words and special chars ↵bsiem2019-08-211-0/+24
| | | | | | | | | | | | | | | | | | | | | | | (GH-14561) Special characters in email address header display names are normally put within double quotes. However, encoded words (=?charset?x?...?=) are not allowed withing double quotes. When the header contains a word with special characters and another word that must be encoded, the first one must also be encoded. In the next example, the display name in the From header is quoted and therefore the comma is allowed; in the To header, the comma is not within quotes and not encoded, which is not allowed and therefore rejected by some mail servers. From: "Foo Bar, France" <foo@example.com> To: Foo Bar, =?utf-8?q?Espa=C3=B1a?= <foo@example.com> https://bugs.python.org/issue37482
* bpo-32178: Fix IndexError trying to parse 'To' header starting with ':'. ↵Abhilash Raj2019-08-111-0/+8
| | | | | | | | | | (GH-15044) This should fix the IndexError trying to retrieve `DisplayName.display_name` and `DisplayName.value` when the `value` is basically an empty string. https://bugs.python.org/issue32178
* bpo-37685: Fixed __eq__, __lt__ etc implementations in some classes. (GH-14952)Serhiy Storchaka2019-08-081-0/+19
| | | | They now return NotImplemented for unsupported type of the other operand.
* Fix typos in comments, docs and test names (#15018)Min ho Kim2019-07-302-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | * 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-172-0/+24
| | | | | | | | | | | | | | | | | | | | | | 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
* Fix IndexError when parsing unexpectedly ending quoted-string. (GH-14813)Abhilash Raj2019-07-171-0/+4
| | | | This exception was caused because the input ended unexpectedly with only one single quote instead of a pair with some value inside it.
* bpo-37461: Fix infinite loop in parsing of specially crafted email headers ↵Abhilash Raj2019-07-171-0/+7
| | | | | | | | | | (GH-14794) * bpo-37461: Fix infinite loop in parsing of specially crafted email headers. Some crafted email header would cause the get_parameter method to run in an infinite loop causing a DoS attack surface when parsing those headers. This patch fixes that by making sure the DQUOTE character is handled to prevent going into an infinite loop.
* Fix infinite loop in email folding logic (GH-12732)Paul Ganssle2019-07-161-0/+20
| | | | | | | | | | As far as I can tell, this infinite loop would be triggered if: 1. The value being folded contains a single word (no spaces) longer than max_line_length 2. The max_line_length is shorter than the encoding's name + 9 characters. bpo-36564: https://bugs.python.org/issue36564
* Remove unused imports in tests (GH-14518)Victor Stinner2019-07-011-1/+0
|
* bpo-29412: Fix indexError when parsing a header value ending unexpectedly ↵Abhilash Raj2019-06-261-0/+17
| | | | | | | (GH-14387) * patched string index out of range error in get_word function of _header_value_parser.py and created tests in test__header_value_parser.py for CFWS. * Raise HeaderParseError instead of continuing when parsing a word.
* bpo-33972: Fix EmailMessage.iter_attachments raising AttributeError. (GH-14119)Abhilash Raj2019-06-251-0/+9
| | | | | | | * 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.
* bpo-36520: Email header folded incorrectly (#13608)websurfer52019-06-061-0/+131
| | | | | | | | | | | | | | | | | * bpo-36520: reset the encoded word offset when starting a new line during an email header folding operation * 📜🤖 Added by blurb_it. * bpo-36520: add an additional test case, and provide descriptive comments for the test_folding_with_utf8_encoding_* tests * bpo-36520: fix whitespace issue * bpo-36520: changes per reviewer request -- remove extraneous backslashes; add whitespace between terminating quotes and line-continuation backslashes; use "bpo-" instead of "issue #" in comments
* bpo-21315: Fix parsing of encoded words with missing leading ws. (#13425)Abhilash Raj2019-06-052-3/+24
| | | | | | | | | | | | * bpo-21315: Fix parsing of encoded words with missing leading ws. Because of missing leading whitespace, encoded word would get parsed as unstructured token. This patch fixes that by looking for encoded words when splitting tokens with whitespace. Missing trailing whitespace around encoded word now register a defect instead. Original patch suggestion by David R. Murray on bpo-21315.
* 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-35805: Add parser for Message-ID email header. (GH-13397)Abhilash Raj2019-06-042-0/+100
| | | | | | | | | | | | | * bpo-35805: Add parser for Message-ID header. This parser is based on the definition of Identification Fields from RFC 5322 Sec 3.6.4. This should also prevent folding of Message-ID header using RFC 2047 encoded words and hence fix bpo-35805. * Prevent folding of non-ascii message-id headers. * Add fold method to MsgID token to prevent folding.
* bpo-27737: Allow whitespace only headers encoding (#13478)Batuhan Taşkaya2019-05-231-0/+3
|
* bpo-33524: Fix the folding of email header when max_line_length is 0 or None ↵Abhilash Raj2019-05-171-0/+13
| | | | | (#13391) and there are non-ascii characters in the header.
* bpo-33529, email: Fix infinite loop in email header encoding (GH-12020)Krzysztof Wojcik2019-05-142-4/+12
|
* bpo-34424: Handle different policy.linesep lengths correctly. (#8803)Jens Troeger2019-05-141-0/+22
|
* bpo-35317: Fix mktime() error in test_email (GH-10721)Victor Stinner2018-11-271-0/+2
| | | | | Fix mktime() overflow error in test_email: run test_localtime_daylight_true_dst_true() and test_localtime_daylight_false_dst_true() with a specific timezone.
* bpo-33476: Fix _header_value_parser when address group is missing final ';' ↵Dong-hee Na2018-07-281-0/+25
| | | | (GH-7484)
* bpo-27397: Make email module properly handle invalid-length base64 strings ↵Tal Einat2018-06-123-0/+32
| | | | | | | (#7583) When attempting to base64-decode a payload of invalid length (1 mod 4), properly recognize and handle it. The given data will be returned as-is, i.e. not decoded, along with a new defect, InvalidBase64LengthDefect.
* bpo-27931: Fix email address header parsing error (#5329)jayyyin2018-01-291-0/+17
| | | | Correctly handle addresses whose username is an empty quoted string.
* bpo-27240 Rewrite the email header folding algorithm. (#3488)R. David Murray2017-12-033-117/+216
| | | | | | | | | | | | | | | | | | | | | The original algorithm tried to delegate the folding to the tokens so that those tokens whose folding rules differed could specify the differences. However, this resulted in a lot of duplicated code because most of the rules were the same. The new algorithm moves all folding logic into a set of functions external to the token classes, but puts the information about which tokens can be folded in which ways on the tokens...with the exception of mime-parameters, which are a special case (which was not even implemented in the old folder). This algorithm can still probably be improved and hopefully simplified somewhat. Note that some of the test expectations are changed. I believe the changes are toward more desirable and consistent behavior: in general when (re) folding a line the canonical version of the tokens is generated, rather than preserving errors or extra whitespace.
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-4/+1
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-30532: Fix whitespace folding in certain casesJoel Hillacre2017-06-261-0/+12
| | | Leading whitespace was incorrectly dropped during folding of certain lines in the _header_value_parser's folding algorithm. This makes the whitespace handling code consistent.
* [email] bpo-29478: Fix passing max_line_length=None from Compat32 policy ↵mircea-cosbuc2017-06-121-0/+7
| | | | | | (GH-595) If max_line_length=None is specified while using the Compat32 policy, it is no longer ignored.
* 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
| |
* | #20476: Deal with the message_factory circular import differently.R David Murray2016-09-101-1/+1
| | | | | | | | | | | | | | 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-092-46/+87
| |
* | Merge with 3.5Steve Dower2016-09-092-3/+32
|\ \ | |/
| * #28047: Fix calculation of base64 line length.R David Murray2016-09-092-3/+32
| | | | | | | | | | This is buggy in the old email code as well, but it doesn't affect anything there because only the default line length is ever used there.
* | #27364: fix "incorrect" uses of escape character in the stdlib.R David Murray2016-09-082-3/+3
| | | | | | | | | | | | | | 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
| |
* | #24277: The new email API is no longer provisional.R David Murray2016-09-081-0/+20
| | | | | | | | | | | | | | 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: #22233: Only split headers on \r and/or \n, per email RFCs.R David Murray2016-09-072-2/+45
|\ \ | |/
| * #22233: Only split headers on \r and/or \n, per email RFCs.R David Murray2016-09-072-2/+45
| | | | | | | | 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.
* | Merge: 27988: Make sure iter_attachments does not mutate the payload list.R David Murray2016-09-071-0/+10
|\ \ | |/
| * 27988: Make sure iter_attachments does not mutate the payload list.R David Murray2016-09-071-0/+10
| |