[issue40597] generated email message exceeds RFC-mandated limit of 998 characters
Abhilash Raj added the comment: Thanks Mark! -- ___ Python tracker <https://bugs.python.org/issue40597> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40597] generated email message exceeds RFC-mandated limit of 998 characters
Abhilash Raj added the comment: Closing this since the PRs for the behavior change reported by Mike and BPO-41206 is now merged too. -- nosy: +maxking stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue40597> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41206] behaviour change with EmailMessage.set_content
Abhilash Raj added the comment: I have merged https://github.com/python/cpython/pull/20542 and backported to 3.8 and 3.9 branches (https://github.com/python/cpython/pull/21404 & https://github.com/python/cpython/pull/21405). Closing this issue. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue41206> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39628] msg.walk memory leak?
Change by Abhilash Raj : -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue39628> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue32021] Brotli encoding is not recognized by mimetypes
Change by Abhilash Raj : -- stage: patch review -> resolved status: open -> closed versions: -Python 3.8 ___ Python tracker <https://bugs.python.org/issue32021> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue32021] Brotli encoding is not recognized by mimetypes
Abhilash Raj added the comment: New changeset b2b4a51f7463a0392456f7772f33223e57fa4ccc by Abhilash Raj (Philip McMahon) in branch 'master': bpo-32021: Support brotli .br encoding in mimetypes (#12200) https://github.com/python/cpython/commit/b2b4a51f7463a0392456f7772f33223e57fa4ccc -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue32021> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39040] Wrong attachement filename when mail mime header was too long
Abhilash Raj added the comment: I double checked, there should be 4 commits in the PR and last 2 have the changes that you asked for in the test case and NEWS entry. Your previous comment will point at the old diff, you might have to look at the full diff here: https://github.com/python/cpython/pull/17620/files or if you want, this is the diff for the 2 commits with the changes you requested: https://github.com/python/cpython/pull/17620/files/bf2cb76009d72869d9df6550b473b5818ceab311..016ceb3ef00b3b940993d35d539ce63d68437d4f -- ___ Python tracker <https://bugs.python.org/issue39040> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39071] email.parser.BytesParser - parse and parsebytes work not equivalent
Change by Abhilash Raj : -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue39071> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39040] Wrong attachement filename when mail mime header was too long
Abhilash Raj added the comment: Sure, fixed as per your comments in the PR. -- ___ Python tracker <https://bugs.python.org/issue39040> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39040] Wrong attachement filename when mail mime header was too long
Abhilash Raj added the comment: Thanks David! I applied the fixes as per your comments, can you please take another look? -- ___ Python tracker <https://bugs.python.org/issue39040> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39040] Wrong attachement filename when mail mime header was too long
Abhilash Raj added the comment: Thanks for the pointer, David! I created a PR for the fix, would you be able to review it please? -- ___ Python tracker <https://bugs.python.org/issue39040> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39040] Wrong attachement filename when mail mime header was too long
Change by Abhilash Raj : -- pull_requests: +17090 pull_request: https://github.com/python/cpython/pull/17620 ___ Python tracker <https://bugs.python.org/issue39040> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39040] Wrong attachement filename when mail mime header was too long
Abhilash Raj added the comment: I tried to take a look at the code to see where the fix needs to be and I probably need some help. I looked at the parse tree for the header and it looks something like this: ContentDisposition([Token([ValueTerminal('attachment')]), ValueTerminal(';'), MimeParameters([Parameter([Attribute([CFWSList([WhiteSpaceTerminal(' ')]), ValueTerminal('filename')]), ValueTerminal('='), Value([QuotedString([BareQuotedString([EncodedWord([ValueTerminal('Schulbesuchsbestättigung.')]), WhiteSpaceTerminal(''), EncodedWord([ValueTerminal('pdf')])])])])])])]) The offending piece of code, which seems to be working as designed is get_bare_quoted_string() in email/_header_value_parser.py. while value and value[0] != '"': if value[0] in WSP: token, value = get_fws(value) elif value[:2] == '=?': try: token, value = get_encoded_word(value) bare_quoted_string.defects.append(errors.InvalidHeaderDefect( "encoded word inside quoted string")) except errors.HeaderParseError: token, value = get_qcontent(value) else: token, value = get_qcontent(value) bare_quoted_string.append(token) It just loops and parses the values. We cannot ignore the FWS until we know that the atom before and after the FWS are encoded words. I can't seem to find a clean way to look-ahead (which can perhaps be used in get_parameters()) or look-back (which can be used after parsing the entire bare_quoted_string?) in the parse tree to delete the offending whitespace. Any example of such kind of parse-tree manipulation in the code base would be awesome! -- versions: +Python 3.9 -Python 3.5, Python 3.6 ___ Python tracker <https://bugs.python.org/issue39040> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38698] While parsing email message id: UnboundLocalError
Abhilash Raj added the comment: Closing this as fixed. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue38698> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38708] parse_message_id in email module is very buggy / crashy
Abhilash Raj added the comment: Closing this as fixed. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue38708> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38708] parse_message_id in email module is very buggy / crashy
Abhilash Raj added the comment: New changeset 3ae4ea1931361dd2743e464790e739d9285501bf by Abhilash Raj in branch 'master': bpo-38708: email: Fix a potential IndexError when parsing Message-ID (GH-17504) https://github.com/python/cpython/commit/3ae4ea1931361dd2743e464790e739d9285501bf -- ___ Python tracker <https://bugs.python.org/issue38708> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38698] While parsing email message id: UnboundLocalError
Abhilash Raj added the comment: New changeset 68157da8b42b26408af5d157d2dba4fcf29c6320 by Abhilash Raj in branch 'master': bpo-38698: Add a new InvalidMessageID token to email header parser. (GH-17503) https://github.com/python/cpython/commit/68157da8b42b26408af5d157d2dba4fcf29c6320 -- ___ Python tracker <https://bugs.python.org/issue38698> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35805] email package folds msg-id identifiers using RFC2047 encoded words where it must not
Abhilash Raj added the comment: Closing this since it has been fixed in Python 3.8. -- resolution: -> fixed stage: needs patch -> resolved status: open -> closed versions: -Python 3.7 ___ Python tracker <https://bugs.python.org/issue35805> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38708] parse_message_id in email module is very buggy / crashy
Change by Abhilash Raj : -- keywords: +patch pull_requests: +16981 stage: -> patch review pull_request: https://github.com/python/cpython/pull/17504 ___ Python tracker <https://bugs.python.org/issue38708> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38698] While parsing email message id: UnboundLocalError
Change by Abhilash Raj : -- pull_requests: +16980 pull_request: https://github.com/python/cpython/pull/17503 ___ Python tracker <https://bugs.python.org/issue38698> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38449] regression - mimetypes guess_type is confused by ; in the filename
Abhilash Raj added the comment: New changeset 2fe4c48917c2d1b40cf063c6ed22ae2e71f4cb62 by Abhilash Raj (Dong-hee Na) in branch 'master': bpo-38449: Add URL delimiters test cases (#16729) https://github.com/python/cpython/commit/2fe4c48917c2d1b40cf063c6ed22ae2e71f4cb62 -- ___ Python tracker <https://bugs.python.org/issue38449> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38332] invalid content-transfer-encoding in encoded-word causes KeyError
Change by Abhilash Raj : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed versions: -Python 3.5, Python 3.6 ___ Python tracker <https://bugs.python.org/issue38332> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38449] regression - mimetypes guess_type is confused by ; in the filename
Abhilash Raj added the comment: New changeset 5a638a805503131f4a9cc2bbc5944611295c1500 by Abhilash Raj in branch '3.8': [3.8] bpo-38449: Revert "bpo-22347: Update mimetypes.guess_type to allow oper parsing of URLs" (GH-16724) (GH-16728) https://github.com/python/cpython/commit/5a638a805503131f4a9cc2bbc5944611295c1500 -- ___ Python tracker <https://bugs.python.org/issue38449> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22347] mimetypes.guess_type("//example.com") misinterprets host name as file name
Abhilash Raj added the comment: New changeset 5a638a805503131f4a9cc2bbc5944611295c1500 by Abhilash Raj in branch '3.8': [3.8] bpo-38449: Revert "bpo-22347: Update mimetypes.guess_type to allow oper parsing of URLs" (GH-16724) (GH-16728) https://github.com/python/cpython/commit/5a638a805503131f4a9cc2bbc5944611295c1500 -- ___ Python tracker <https://bugs.python.org/issue22347> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38449] regression - mimetypes guess_type is confused by ; in the filename
Abhilash Raj added the comment: corona10: That's okay, it happens. I missed it too. There was really no way to foresee all the use cases, which is why we have beta and rc period to catch bugs. Yes, we should add a test case definitely, do you want to work on a PR? -- ___ Python tracker <https://bugs.python.org/issue38449> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22347] mimetypes.guess_type("//example.com") misinterprets host name as file name
Abhilash Raj added the comment: I am going to re-open this since the fixes were reverted in all the branches. -- status: closed -> open ___ Python tracker <https://bugs.python.org/issue22347> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38341] Add SMTPNotSupportedError in the exports of smtplib
Change by Abhilash Raj : -- stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue38341> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22347] mimetypes.guess_type("//example.com") misinterprets host name as file name
Change by Abhilash Raj : -- pull_requests: +16310 pull_request: https://github.com/python/cpython/pull/16728 ___ Python tracker <https://bugs.python.org/issue22347> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38449] regression - mimetypes guess_type is confused by ; in the filename
Change by Abhilash Raj : -- pull_requests: +16309 pull_request: https://github.com/python/cpython/pull/16728 ___ Python tracker <https://bugs.python.org/issue38449> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38449] regression - mimetypes guess_type is confused by ; in the filename
Change by Abhilash Raj : -- pull_requests: +16308 pull_request: https://github.com/python/cpython/pull/16727 ___ Python tracker <https://bugs.python.org/issue38449> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22347] mimetypes.guess_type("//example.com") misinterprets host name as file name
Change by Abhilash Raj : -- pull_requests: +16307 pull_request: https://github.com/python/cpython/pull/16727 ___ Python tracker <https://bugs.python.org/issue22347> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22347] mimetypes.guess_type("//example.com") misinterprets host name as file name
Change by Abhilash Raj : -- pull_requests: +16303 pull_request: https://github.com/python/cpython/pull/16724 ___ Python tracker <https://bugs.python.org/issue22347> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38449] regression - mimetypes guess_type is confused by ; in the filename
Change by Abhilash Raj : -- keywords: +patch pull_requests: +16302 stage: -> patch review pull_request: https://github.com/python/cpython/pull/16724 ___ Python tracker <https://bugs.python.org/issue38449> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38449] regression - mimetypes guess_type is confused by ; in the filename
Abhilash Raj added the comment: Yeah, I agree. I'll submit a PR for reverting the commits. -- ___ Python tracker <https://bugs.python.org/issue38449> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38449] regression - mimetypes guess_type is confused by ; in the filename
Abhilash Raj added the comment: The bug is interesting due to some of the implementation details of "guess_type". The documentation says that it can parse either a URL or a filename. Switching from urllib.parse._splittype to urllib.parse.urlparse changed what a valid "path" is. _splittype doesn't care about the rest of the URL except the scheme, but urlparse does. Previously, we used to split things like: >>> print(urllib.parse._splittype(';1.tar.gz') (None, ';1.tar.gz') Then, we'd just treat the 2nd part as a filesystem path, which would rightfully guess the extension as .tar.gz However, switching to using parsing via urllib.parse.urlparse, we get: >>> print(urllib.parse.urlparse(';1.tar.gz') ParseResult(scheme='', netloc='', path='', params='1.tar.gz', query='', fragment='') And then we get the ".path" attribute for further processing, which being empty, returns (None, None). The format of all these parts is: scheme://netloc/path;parameters?query#fragment A simple fix would be to just merge path, parameters, query and fragment together (with appropriate delimiters) and the proceed with further processing. That would fix parsing of Filesystem paths but would break (again) parsing of URLs like: >>> mimetypes.guess_type('http://example.com/index.html;1.tar.gz') ('application/x-tar', 'gzip') It should return 'text/html' as the type, since this is a URL and everything after the ';' should not be used to determine the mimetype. But, if there is no scheme provided, we should treat it as a filesystem path and in that case 'application/x-tar' is the right type. I hope I am not confusing everyone here. The right fix IMO would be to make "guess_type" not treat URLs and filesytem paths alike. -- ___ Python tracker <https://bugs.python.org/issue38449> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38449] regression - mimetypes guess_type is confused by ; in the filename
Abhilash Raj added the comment: I am looking into the issue. -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue38449> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21360] mailbox.Maildir should ignore files named with a leading dot
Abhilash Raj added the comment: David: How do you propose we move forward on this? Should we provide a switch to keep the original behaviour (which is off by default) so if there is someone depending on this bug, they could still continue to do it with relatively small change? It is a change of behaviour, so probably isn't going to be back ported if it gets merged in 3.9 window. -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue21360> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38332] invalid content-transfer-encoding in encoded-word causes KeyError
Abhilash Raj added the comment: New changeset 65dcc8a8dc41d3453fd6b987073a5f1b30c5c0fd by Abhilash Raj (Andrei Troie) in branch 'master': bpo-38332: Catch KeyError from unknown cte in encoded-word. (GH-16503) https://github.com/python/cpython/commit/65dcc8a8dc41d3453fd6b987073a5f1b30c5c0fd -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue38332> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38349] Email example using imaginary library installation error.
Abhilash Raj added the comment: We could move that comment to the top near the import, I am totally fine with that. -- ___ Python tracker <https://bugs.python.org/issue38349> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38349] Email example using imaginary library installation error.
Abhilash Raj added the comment: The comment should make it clear that it is an made up imaginary module. The no dependencies outside of standard library is not written, I guess? -- ___ Python tracker <https://bugs.python.org/issue38349> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38349] Email example using imaginary library installation error.
Abhilash Raj added the comment: The function of this imaginary method is described below: # The magic_html_parser has to rewrite the href="cid:" attributes to # point to the filenames in partfiles. It also has to do a safety-sanitize # of the html. It could be written using html.parser. This implementation is going to be non-trivial (more than just a wrapper around html.parser) I think, and I would like to not make the example related to email even longer due to that implementation. And I agree with Terry, the comment should make it pretty clear, there aren't any dependencies in the examples outside of standard library. Any other synonym that we'd choose could end up being a package in pypi someday :) -- ___ Python tracker <https://bugs.python.org/issue38349> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38232] empty local-part in addr_spec displayed incorrectly
Abhilash Raj added the comment: It is actually parsed correctly and serialized back when you try to convert it to a string representation: from email.parser import BytesFeedParser import email.policy def main(): eml_string = 'From: Nobody <""@example.org>' parser = BytesFeedParser(policy = email.policy.default) parser.feed(eml_string.encode()) msg = parser.close() print(msg.get('From').addresses[0].addr_spec) print(repr(msg.get('From')._parse_tree)) print(msg.as_string()) Running this gives me: @example.org AddressList([Address([Mailbox([NameAddr([DisplayName([Atom([ValueTerminal('Nobody'), CFWSList([WhiteSpaceTerminal(' ')])])]), AngleAddr([ValueTerminal('<'), AddrSpec([LocalPart([QuotedString([BareQuotedString([ValueTerminal('')])])]), ValueTerminal('@'), Domain([DotAtom([DotAtomText([ValueTerminal('example'), ValueTerminal('.'), ValueTerminal('org')])])])]), ValueTerminal('>')])])])])]) From: Nobody <""@example.org> Notice the : AddrSpec([LocalPart([QuotedString([BareQuotedString([ValueTerminal('')])])]) print() converts the addr-spec into a string, which omits the quotes. This is true for any non-none string too: he...@example.org AddressList([Address([Mailbox([NameAddr([DisplayName([Atom([ValueTerminal('Nobody'), CFWSList([WhiteSpaceTerminal(' ')])])]), AngleAddr([ValueTerminal('<'), AddrSpec([LocalPart([QuotedString([BareQuotedString([ValueTerminal('hello')])])]), ValueTerminal('@'), Domain([DotAtom([DotAtomText([ValueTerminal('example'), ValueTerminal('.'), ValueTerminal('org')])])])]), ValueTerminal('>')])])])])]) From: Nobody <"hello"@example.org> If you prefer the string representation of the header's parsed value, you can try: print(msg.get('From').fold(policy=email.policy.default)) Which prints: From: Nobody <""@example.org> -- ___ Python tracker <https://bugs.python.org/issue38232> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38341] Add SMTPNotSupportedError in the exports of smtplib
Abhilash Raj added the comment: New changeset 3faf826e5879536d2272f1a51c58965a16827f81 by Abhilash Raj (nde) in branch 'master': bpo-38341: Add SMTPNotSupportedError in the exports of smtplib (#16525) https://github.com/python/cpython/commit/3faf826e5879536d2272f1a51c58965a16827f81 -- ___ Python tracker <https://bugs.python.org/issue38341> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38341] Add SMTPNotSupportedError in the exports of smtplib
Abhilash Raj added the comment: It seems that SMTPNotSupportedError is publicly documented, it should be a part of __all__. -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue38341> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34002] minor efficiency and clarity improvements in email package
Abhilash Raj added the comment: PR is now merged. -- stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue34002> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34002] minor efficiency and clarity improvements in email package
Abhilash Raj added the comment: New changeset 2702638eabe5f7b25f36d295f0ad78cb8d4eda05 by Abhilash Raj (Michael Selik) in branch 'master': bpo-34002: Minor efficiency and clarity improvements in email package. (GH-7999) https://github.com/python/cpython/commit/2702638eabe5f7b25f36d295f0ad78cb8d4eda05 -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue34002> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24363] httplib fails to handle semivalid HTTP headers
Abhilash Raj added the comment: Martin: Can you please create a PR for the added patch? If you are busy, I can do that for you, just wanted to ask before I do :) I am going to remove "easy" label from this issue, which IMO it clearly isn't given 4 years of history to catch up on and a few other related bugs. Since some time has passed since the patch was posted, I am going to target this to 3.8 and 3.7 since others are in security fix mode only. -- keywords: -easy, patch nosy: +maxking versions: +Python 3.8 -Python 2.7, Python 3.5, Python 3.6 ___ Python tracker <https://bugs.python.org/issue24363> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34155] [CVE-2019-16056] email.utils.parseaddr mistakenly parse an email
Abhilash Raj added the comment: Merged in 2.7, closing this one finally! Thanks to everyone who helped with this :) -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue34155> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37764] email.Message.as_string infinite loop
Change by Abhilash Raj : -- resolution: -> fixed ___ Python tracker <https://bugs.python.org/issue37764> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22347] mimetypes.guess_type("//example.com") misinterprets host name as file name
Abhilash Raj added the comment: I think so, yes. Also, while you are at it, can you also close bpo-35939 with a comment that points to this issue and the right PR for the fix? -- ___ Python tracker <https://bugs.python.org/issue22347> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37764] email.Message.as_string infinite loop
Change by Abhilash Raj : -- stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue37764> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37764] email.Message.as_string infinite loop
Abhilash Raj added the comment: New changeset 6ad0a2c45f78020f7994e47620c1cf7b225f8197 by Abhilash Raj in branch '3.8': [3.8] bpo-37764: Fix infinite loop when parsing unstructured email headers. (GH-15239) (GH-15686) https://github.com/python/cpython/commit/6ad0a2c45f78020f7994e47620c1cf7b225f8197 -- ___ Python tracker <https://bugs.python.org/issue37764> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37764] email.Message.as_string infinite loop
Change by Abhilash Raj : -- pull_requests: +15344 pull_request: https://github.com/python/cpython/pull/15686 ___ Python tracker <https://bugs.python.org/issue37764> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37461] email.parser.Parser hang
Abhilash Raj added the comment: I manually created a backport PR for 3.5 and added Larry as a reviewer. https://github.com/python/cpython/pull/15446 -- ___ Python tracker <https://bugs.python.org/issue37461> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37461] email.parser.Parser hang
Change by Abhilash Raj : -- pull_requests: +15138 pull_request: https://github.com/python/cpython/pull/15446 ___ Python tracker <https://bugs.python.org/issue37461> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue32793] smtplib: duplicated debug message
Abhilash Raj added the comment: Removing 2.7 which only accepts security patches. -- nosy: +maxking versions: -Python 2.7 ___ Python tracker <https://bugs.python.org/issue32793> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34155] email.utils.parseaddr mistakenly parse an email
Abhilash Raj added the comment: 2.7 needs a separate PR since the code is very different and my familiarity with 2.7 version of email package is very limited. I am going to work on a separate patch later this week for 2.7. -- ___ Python tracker <https://bugs.python.org/issue34155> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35805] email package folds msg-id identifiers using RFC2047 encoded words where it must not
Abhilash Raj added the comment: I am slightly confused if this should be backported to bugfix branches since this is technically a new feature, the ability to parse Message-ID field. I would love to see what David and Barry think about this? -- ___ Python tracker <https://bugs.python.org/issue35805> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21315] email._header_value_parser does not recognise in-line encoding changes
Change by Abhilash Raj : -- stage: patch review -> resolved status: open -> closed versions: +Python 3.7, Python 3.8 -Python 3.3, Python 3.4, Python 3.5 ___ Python tracker <https://bugs.python.org/issue21315> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29412] IndexError thrown on email.message.Message.get
Change by Abhilash Raj : -- stage: patch review -> resolved status: open -> closed versions: +Python 3.8, Python 3.9 -Python 3.5, Python 3.6 ___ Python tracker <https://bugs.python.org/issue29412> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34155] email.utils.parseaddr mistakenly parse an email
Abhilash Raj added the comment: Created a backport PR for 3.5. -- stage: patch review -> resolved ___ Python tracker <https://bugs.python.org/issue34155> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34155] email.utils.parseaddr mistakenly parse an email
Change by Abhilash Raj : -- pull_requests: +15036 stage: resolved -> patch review pull_request: https://github.com/python/cpython/pull/15317 ___ Python tracker <https://bugs.python.org/issue34155> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37826] Document PEP 3134 in tutorials/errors.rst
Change by Abhilash Raj : -- stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue37826> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37764] email.Message.as_string infinite loop
Abhilash Raj added the comment: Although, the 2nd bug I spoke of is kind of speculative, I haven't been able to find a test case which matches rfc2047_matcher but raises exception with get_encoded_word (after, ofcourse, the first bug is fixed), which the only way to cause an infinite loop. -- ___ Python tracker <https://bugs.python.org/issue37764> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37764] email.Message.as_string infinite loop
Abhilash Raj added the comment: I meant, =aa is identified as encoded word escape -- ___ Python tracker <https://bugs.python.org/issue37764> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37764] email.Message.as_string infinite loop
Abhilash Raj added the comment: You have correctly identified that "=aa" is detected as a encoded word and causes the get_encoded_word to fail. However, "=?utf-8?q?somevalue?=aa" should ideally get parsed as "somevalueaa" and not "=?utf-8?q?somevalue?=aa". This is because "=?utf-8?q?somevalue?=" is a valid encoded word, it is just not followed by an empty whitespace. modified Lib/email/_header_value_parser.py @@ -1037,7 +1037,10 @@ def get_encoded_word(value): raise errors.HeaderParseError( "expected encoded word but found {}".format(value)) remstr = ''.join(remainder) -if len(remstr) > 1 and remstr[0] in hexdigits and remstr[1] in hexdigits: +if (len(remstr) > 1 and +remstr[0] in hexdigits and +remstr[1] in hexdigits and +tok.count('?') < 2): # The ? after the CTE was followed by an encoded word escape (=XX). rest, *remainder = remstr.split('?=', 1) This can be avoided by checking `?` occurs twice in the `tok`. The 2nd bug, which needs a better test case, is that if the encoded_word is invalid, you will keep running into infinite loop, which you correctly fixed in your PR. However, the test case you used is more appropriate for the first issue. You can fix both the issues, for which, you need to add a test case for 2nd issue and fix for the first issue. Looking into the PR now. -- ___ Python tracker <https://bugs.python.org/issue37764> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34155] email.utils.parseaddr mistakenly parse an email
Abhilash Raj added the comment: @Victor: This is already backported to 3.6. I am not sure about what gets backported to 3.5 right now, I don't even see a 'Backport to 3.5' label on Github (which made me think we are discouraged to backport to 3.5). I can work on a manual backport if needed? This patch most probably won't backport to 2.7 without re-writing it completely since the implementation in 2.7 is much different than what we have today. -- ___ Python tracker <https://bugs.python.org/issue34155> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37826] Document PEP 3134 in tutorials/errors.rst
Change by Abhilash Raj : -- keywords: +patch pull_requests: +14964 stage: -> patch review pull_request: https://github.com/python/cpython/pull/15243 ___ Python tracker <https://bugs.python.org/issue37826> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37826] Document PEP 3134 in tutorials/errors.rst
Abhilash Raj added the comment: Yes, I am gonna work on a PR. -- ___ Python tracker <https://bugs.python.org/issue37826> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue32178] Some invalid email address groups cause an IndexError instead of a HeaderParseError
Change by Abhilash Raj : -- stage: patch review -> resolved status: open -> closed versions: +Python 3.7, Python 3.8, Python 3.9 -Python 3.4, Python 3.5, Python 3.6 ___ Python tracker <https://bugs.python.org/issue32178> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37826] Document PEP 3134 in tutorials/errors.rst
New submission from Abhilash Raj : Looking at the docs, I couldn't find the `raise from` documentation anywhere in the Errors and Exceptions page (https://docs.python.org/3/tutorial/errors.html) page, which seems to be the landing page for Python Exceptions. I do see however that it is documented on the top page of https://docs.python.org/3/library/exceptions.html and raise statement's docs (https://docs.python.org/3/reference/simple_stmts.html#raise), both of which are pretty hard to discover. It would be nice to add the docs for `raise from` in the Errors and Exception page too. -- assignee: docs@python components: Documentation messages: 349406 nosy: docs@python, maxking priority: normal severity: normal status: open title: Document PEP 3134 in tutorials/errors.rst ___ Python tracker <https://bugs.python.org/issue37826> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37764] email.Message.as_string infinite loop
Abhilash Raj added the comment: Adding security label since this can cause DOS. -- type: -> security ___ Python tracker <https://bugs.python.org/issue37764> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34155] email.utils.parseaddr mistakenly parse an email
Abhilash Raj added the comment: Closing this since teh PRs are merged. -- stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue34155> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37764] email.Message.as_string infinite loop
Change by Abhilash Raj : -- versions: +Python 3.8 ___ Python tracker <https://bugs.python.org/issue37764> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37764] email.Message.as_string infinite loop
Abhilash Raj added the comment: This does look like a side-effect of the commit mentioned by mytran. The issues seems to be that email._header_value_parser.get_unstructured wrongfully assumes that anything leading with '=?' would be a valid rfc 2047 encoded word. This is a smaller test case to reproduce this bug: from email._header_value_parser import get_unstructured get_unstructured('=?utf-8?q?FSaiz4vX3XMJPT4vrExGUZeOnp0o22pLBB7CYLH74Js=3DwOlK6Tfru2U47qR?=72OfyEY2p2/rA9xNFyvH+fBTCmazxwzF8nGkK6D') -- ___ Python tracker <https://bugs.python.org/issue37764> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue32178] Some invalid email address groups cause an IndexError instead of a HeaderParseError
Change by Abhilash Raj : -- pull_requests: +14799 stage: resolved -> patch review pull_request: https://github.com/python/cpython/pull/15044 ___ Python tracker <https://bugs.python.org/issue32178> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37491] IndexError in get_bare_quoted_string
Change by Abhilash Raj : -- pull_requests: +14607 stage: -> patch review pull_request: https://github.com/python/cpython/pull/14813 ___ Python tracker <https://bugs.python.org/issue37491> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37461] email.parser.Parser hang
Abhilash Raj added the comment: I have proposed a PR for this: https://github.com/python/cpython/pull/14794 Reviews are welcome. -- ___ Python tracker <https://bugs.python.org/issue37461> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37461] email.parser.Parser hang
Change by Abhilash Raj : -- pull_requests: +14588 pull_request: https://github.com/python/cpython/pull/14794 ___ Python tracker <https://bugs.python.org/issue37461> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37491] IndexError in get_bare_quoted_string
Abhilash Raj added the comment: I just wanted to report before I forgot and hence missed some details, turns out the bug report was slightly wrong too. The testcase I provided wasn't right. Here is the right test case to reproduce the exception with master: # bpo_37491.py from email.parser import BytesParser, Parser from email.policy import default payload = 'Content-Type:"' msg = Parser(policy=default).parsestr(payload) print(msg.get('content-type')) $ ./python bpo_37491.py Traceback (most recent call last): File "bpo_37491.py", line 5, in msg = Parser(policy=default).parsestr(payload) File "/home/maxking/Documents/cpython/Lib/email/parser.py", line 68, in parsestr return self.parse(StringIO(text), headersonly=headersonly) File "/home/maxking/Documents/cpython/Lib/email/parser.py", line 58, in parse return feedparser.close() File "/home/maxking/Documents/cpython/Lib/email/feedparser.py", line 187, in close self._call_parse() File "/home/maxking/Documents/cpython/Lib/email/feedparser.py", line 180, in _call_parse self._parse() File "/home/maxking/Documents/cpython/Lib/email/feedparser.py", line 256, in _parsegen if self._cur.get_content_type() == 'message/delivery-status': File "/home/maxking/Documents/cpython/Lib/email/message.py", line 578, in get_content_type value = self.get('content-type', missing) File "/home/maxking/Documents/cpython/Lib/email/message.py", line 471, in get return self.policy.header_fetch_parse(k, v) File "/home/maxking/Documents/cpython/Lib/email/policy.py", line 163, in header_fetch_parse return self.header_factory(name, value) File "/home/maxking/Documents/cpython/Lib/email/headerregistry.py", line 602, in __call__ return self[name](name, value) File "/home/maxking/Documents/cpython/Lib/email/headerregistry.py", line 197, in __new__ cls.parse(value, kwds) File "/home/maxking/Documents/cpython/Lib/email/headerregistry.py", line 447, in parse kwds['decoded'] = str(parse_tree) File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 126, in __str__ return ''.join(str(x) for x in self) File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 126, in return ''.join(str(x) for x in self) File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 796, in __str__ for name, value in self.params: File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 770, in params value = param.param_value File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 679, in param_value return token.stripped_value File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 710, in stripped_value token = self[0] IndexError: list index out of range This time I attached a correct patch instead of copy-pasting only the diff :) About IndexError, I agree, it must be an empty string value and not a None value. -- keywords: +patch Added file: https://bugs.python.org/file48462/fix-indexerror.patch ___ Python tracker <https://bugs.python.org/issue37491> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37491] IndexError in get_bare_quoted_string
Abhilash Raj added the comment: Thanks for the explanation Terry! In this case, value becomes None (I think), which causes the IndexError. -- ___ Python tracker <https://bugs.python.org/issue37491> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37491] IndexError in get_bare_quoted_string
New submission from Abhilash Raj : from email.parser import BytesParser, Parser from email.policy import default payload = 'Content-Type:x;\x1b*="\'G\'\\"""""' msg = Parser(policy=default).parsestr(payload) print(msg.get('content-type')) When trying to review PR for BPO 37461, I found another bug where an IndexError is raised if there aren't closing quote characters in the input message: Suggested patch: @@ -1191,7 +1192,7 @@ def get_bare_quoted_string(value): "expected '\"' but found '{}'".format(value)) bare_quoted_string = BareQuotedString() value = value[1:] -if value[0] == '"': +if value and value[0] == '"': token, value = get_qcontent(value) bare_quoted_string.append(token) while value and value[0] != '"': -- components: email messages: 347190 nosy: barry, maxking, r.david.murray priority: normal severity: normal status: open title: IndexError in get_bare_quoted_string type: crash versions: Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue37491> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29412] IndexError thrown on email.message.Message.get
Change by Abhilash Raj : -- pull_requests: +14201 pull_request: https://github.com/python/cpython/pull/14387 ___ Python tracker <https://bugs.python.org/issue29412> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33972] AttributeError in email.message.iter_attachments()
Change by Abhilash Raj : -- pull_requests: +14195 pull_request: https://github.com/python/cpython/pull/14381 ___ Python tracker <https://bugs.python.org/issue33972> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33972] AttributeError in email.message.iter_attachments()
Change by Abhilash Raj : -- pull_requests: +14194 pull_request: https://github.com/python/cpython/pull/14380 ___ Python tracker <https://bugs.python.org/issue33972> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33972] AttributeError in email.message.iter_attachments()
Change by Abhilash Raj : -- pull_requests: +13968 pull_request: https://github.com/python/cpython/pull/14119 ___ Python tracker <https://bugs.python.org/issue33972> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26543] [EASY] imaplib noop Debug: bytes vs Unicode bug in debug mode
Change by Abhilash Raj : -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue26543> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4963] mimetypes.guess_extension result changes after mimetypes.init()
Change by Abhilash Raj : -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue4963> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29412] IndexError thrown on email.message.Message.get
Abhilash Raj added the comment: Nevermind, I was wrong, I was able to reproduce it: >>> msg = email.message_from_string('To: (Recipient list suppressed)', >>> policy=email.policy.default)) File "", line 1 SyntaxError: unmatched ')' >>> msg = email.message_from_string('To: (Recipient list suppressed)', >>> policy=email.policy.default) >>> msg.get('to') Traceback (most recent call last): File "", line 1, in File "/home/maxking/Documents/cpython/Lib/email/message.py", line 471, in get return self.policy.header_fetch_parse(k, v) File "/home/maxking/Documents/cpython/Lib/email/policy.py", line 163, in header_fetch_parse return self.header_factory(name, value) File "/home/maxking/Documents/cpython/Lib/email/headerregistry.py", line 589, in __call__ return self[name](name, value) File "/home/maxking/Documents/cpython/Lib/email/headerregistry.py", line 197, in __new__ cls.parse(value, kwds) File "/home/maxking/Documents/cpython/Lib/email/headerregistry.py", line 340, in parse kwds['parse_tree'] = address_list = cls.value_parser(value) File "/home/maxking/Documents/cpython/Lib/email/headerregistry.py", line 331, in value_parser address_list, value = parser.get_address_list(value) File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 1951, in get_address_list token, value = get_address(value) File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 1928, in get_address token, value = get_group(value) File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 1884, in get_group token, value = get_display_name(value) File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 1710, in get_display_name token, value = get_phrase(value) File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 1385, in get_phrase token, value = get_word(value) File "/home/maxking/Documents/cpython/Lib/email/_header_value_parser.py", line 1360, in get_word if value[0]=='"': IndexError: string index out of range -- ___ Python tracker <https://bugs.python.org/issue29412> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29412] IndexError thrown on email.message.Message.get
Abhilash Raj added the comment: For the record, this is how I tested using the master branch: >>> msg = email.message_from_string(' To: (Recipient list suppressed)') >>> msg['To'] >>> import email.policy >>> msg = email.message_from_string(' To: (Recipient list suppressed)', >>> policy=email.policy.default) >>> msg >>> msg['To'] >>> msg.get('to') -- ___ Python tracker <https://bugs.python.org/issue29412> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29412] IndexError thrown on email.message.Message.get
Abhilash Raj added the comment: I can't reproduce this problem with the latest master branch, it was perhaps fixed with some other PR. This is also a dupe of bpo-31445. @barry, @david: I think this issue can be closed. -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue29412> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31445] Index out of range in get of message.EmailMessage.get()
Abhilash Raj added the comment: I can't reproduce this issue on the latest master branch. This seems to be fixed as a part of a different PR I suppose. >>> import email >>> msg = email.message_from_string("From: Bonifac Karaka : boni...@gmail.com") >>> msg['From'] 'Bonifac Karaka : boni...@gmail.com' This is very similar to bpo-32178, which also is now fixed. @david, @barry, I think we can close this issue. -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue31445> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue32179] Empty email address in headers triggers an IndexError
Abhilash Raj added the comment: I wasn't able to reproduce this on the latest master. Probably fixed as a part of some other PR. >>> msg = email.message_from_string('ReplyTo: ""') >>> msg >>> msg['ReplyTo'] '""' I think this issue can be closed. -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue32179> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue32178] Some invalid email address groups cause an IndexError instead of a HeaderParseError
Abhilash Raj added the comment: I don't think this is an issue anymore, I guess this was fixed as a part of some other PR. I tested this out on a recent branch: >>> import email >>> msg = email.message_from_string('From: Abhilash ') >>> msg['From'] 'Abhilash ' @david, @barry: I think we can close this issue. -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue32178> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36520] Email header folded incorrectly
Change by Abhilash Raj : -- pull_requests: +13782 pull_request: https://github.com/python/cpython/pull/13909 ___ Python tracker <https://bugs.python.org/issue36520> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36520] Email header folded incorrectly
Change by Abhilash Raj : -- pull_requests: +13783 pull_request: https://github.com/python/cpython/pull/13910 ___ Python tracker <https://bugs.python.org/issue36520> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34155] email.utils.parseaddr mistakenly parse an email
Abhilash Raj added the comment: slight typo in the previous message: s/fallback to `get_unstructured` /fallback to *something*/g -- ___ Python tracker <https://bugs.python.org/issue34155> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34155] email.utils.parseaddr mistakenly parse an email
Abhilash Raj added the comment: I agree that we currently abandon parsing (raise `HeaderParseError`) when we encounter a unexpected token when parsing domain (expected token is dot-atom-text). However, that mechanism is meant to signal the higher level parser that we should look for a different type of token. In case of domain, we don't fallback to anything. I believe we should fallback to `get_unstructured` when we do encounter an invalid domain (either `foo.` or `foo@exaomple` or `f...@example.com`) and register defect. But, the `.domain` attribute on the address class should be None if the domain is invalid. My proposed solution of `get_unstrucutured` is perhaps not a great idea either since we would end up parsing more than we should (maybe we should parse until `>`?) in case of AddrList or something. I would love to know what David and Barry think about this one? -- ___ Python tracker <https://bugs.python.org/issue34155> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34155] email.utils.parseaddr mistakenly parse an email
Abhilash Raj added the comment: I don't know if we can make the API consistent between parseaddr and the parsing header value since they are completely different even right now. Like you already noticed there is no way to register defects and instead parseaddr returns ('', '') to denote the failure to parse. About parsing malicious domain, my line of thinking was along the lines of presenting whatever is there to user of the API, without 'hiding' that information. It would be harder to figure out the exception if the domain is missing. Even though the domain is parsed in the `domain` value, the value itself is clearly invalid. Any attempt to ever use that Address() will definitely cause an error (perhaps, there should be a sanity check in SMTP.send_message for that?). -- ___ Python tracker <https://bugs.python.org/issue34155> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34155] email.utils.parseaddr mistakenly parse an email
Abhilash Raj added the comment: How about we go a slightly different route than suggested by jpic and instead of returning a None value, we return the entire rest of the string as the domain? That would take care of the security issue since it won't be a valid domain anymore. msg = email.message_from_string( 'From: SomeAbhilashRaj ', policy=email.policy.default) print(msg['From'].addresses) print(msg['From'].defects) (Address(display_name='SomeAbhilashRaj', username='abhilash', domain='malicious@important.com>'),) (InvalidHeaderDefect('invalid address in address-list'), InvalidHeaderDefect("missing trailing '>' on angle-addr"), InvalidHeaderDefect("unpected '@' in domain"), ObsoleteHeaderDefect("period in 'phrase'")) This lets us do postel-style error recovery while working in RFC 2822 style grammar. I wrote this patch to achieve this: @@ -1573,6 +1574,11 @@ def get_domain(value): domain.append(DOT) token, value = get_atom(value[1:]) domain.append(token) +if value and value[0] == '@': +domain.defects.append(errors.InvalidHeaderDefect( +"unpected '@' in domain")) +token = get_unstructured(value) +domain.append(token) return domain, value Does this makes sense? -- nosy: +maxking ___ Python tracker <https://bugs.python.org/issue34155> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com