jpic <j...@yourlabs.org> added the comment:
At is allowed in the local part if quoted, the proposed patch acts within get_domain() and getdomain() and does not affect local part parsing. This still works: >>> parseaddr('"fo@bar"@bar.com') ('', '"fo@bar"@bar.com') >>> email.message_from_string('From: "a@b"@ex.com ',policy=email.policy.default)['from'].addresses (Address(display_name='', username='a@b', domain='ex.com'),) I'm not against raising an exception in parseaddr, but you should know that currently nothing in parseaddr seems to raise an exception: jpic@ci:~/cpython$ grep raise Lib/email/_parseaddr.py jpic@ci:~/cpython$ For example: >>> parseaddr('aoeu') ('', 'aoeu') >>> parseaddr('a@') ('', 'a@') None of the above calls raised an exception. That is the reason why I did not introduce a new Exception in the getdomain() change: I thought it would be more consistent with the rest of the API as such. As for the new API, the patch does raise a parse error: # this detect that the next caracter right after the parsed domain is another @ if value and value[0] == '@': raise errors.HeaderParseError('Multiple domains') But that's in the lower level API that is planned for going public later on (probably when it will have unit tests), it's just the higher level API that the user faces that swallows it. As a user you can still know about that parse problem using the defects attribute: >>> email.message_from_string('From: a...@malicious.org@example.com', policy=email.policy.default)['from'].defects[0] InvalidHeaderDefect('invalid address in address-list') ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34155> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com