-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
email.utils.getaddresses does not handle Header objects #71700
Comments
An unfortunate combination of get_all and getaddresses results in a Traceback: Traceback (most recent call last):
File "misc/decode_from_header.py", line 17, in <module>
print('From: %s' % email.utils.getaddresses(val))
File "/usr/lib64/python3.4/email/utils.py", line 112, in getaddresses
all = COMMASPACE.join(fieldvalues)
TypeError: sequence item 0: expected str instance, Header found Here's the relevant part of it: Obviously, the From header is iso-8859-1 encoded as well, and violates RFC 2822 as such. But making it crash in the usual combination of val = msg.get('from')
email.utils.getaddresses([val]) isn't the real McCoy either.. |
message.get cannot decode the header correctly, and returns a Header instance instead, which makes email.utils.getaddresses stumble upon... A much better behavior for getaddresses in this case would be returning the perfectly valid address, and ignoring the invalid dtext part. |
This appears to be something that was overlooked when btyes support was added in 3.2. getaddresses should indeed be able to handle a Header object if handed one. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: