Torsten Becker <[email protected]> added the comment:
Hi, here is my revised patch with email.utils.getaddresses() also decoding IDNs.
I decided to integrate IDN decoding in AddrlistClass.getaddress() instead of
AddrlistClass.getaddrlist() since that function is one level lower and if
somebody should ever all it directly, the conversion would not happen.
I also fixed a glitch in the docs, "versionchanged" seems to need two colons to
end up in the generated HTML.
As a follow up, wouldn't it be helpful if email.Message would do the
conversions directly? So when you parse a mail into a Message and access the
"To" field, you get a list of tuples which are decoded properly?
For example the following test currently still fails because the quoted header
value is not decoded by email.feedparser.FeedParser nor email.Message:
def test_email_decodes_idns_and_unicode(self):
text = '''\
To: =?utf-8?b?SMOkbnMgV8O8cnN0?= <[email protected]>
Hello World!'''
msg = Parser().parsestr(text)
self.assertEqual(utils.getaddresses(msg.get_all('To')),
[('H\xe4ns W\xfcrst', 'hans@d\xf6m.ain')])
Am I using the package wrong here or is this actually missing?
email.header.decode_header seems to be able to do this already but it is not
used. Would it be safe to integrate this into the
email.message._sanitize_header helper?
----------
Added file: http://bugs.python.org/file21698/issue-11783-v4.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue11783>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com