[New-bugs-announce] [issue18044] Email headers do not properly decode to unicode.
Tim Rawlinson
report at bugs.python.org
Thu May 23 13:57:36 CEST 2013
New submission from Tim Rawlinson:
In Python 3.3 decoding of headers to unicode is supposed to be automatic but fails in several cases, including one shown as successful in the documentation:
>>> msg = message_from_string('Subject: =?utf-8?q?=C3=89ric?=\n\n', policy=default)
>>> msg['Subject']
'=?utf-8?q?=C3=89ric?='
>>> msg = message_from_string('To: =?utf-8?q?=C3=89ric <foo at example.com>\n\n', policy=default)
>>> msg['To']
'=?utf-8?q?=C3=89ric?= <foo at example.com>'
Although the following works:
>>> msg = message_from_string('Subject: =?utf-8?q?Eric?=\n\n', policy=default)
>>> msg['Subject']
'Eric'
Though this does not:
>>> msg = message_from_string('To: =?utf-8?q?Eric?= <foo at example.com>\n\n', policy=default)
>>> msg['To']
'=?utf-8?q?Eric?= <foo at example.com>'
And just to prove some things are working as they should:
>>> msg = message_from_string("Subject: =?gb2312?b?1eLKx9bQzsSy4srUo6E=?=\n\n", policy=default)
>>> msg['Subject']
'这是中文测试!'
----------
assignee: docs at python
components: Documentation, email
messages: 189862
nosy: Tim.Rawlinson, barry, docs at python, r.david.murray
priority: normal
severity: normal
status: open
title: Email headers do not properly decode to unicode.
type: behavior
versions: Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18044>
_______________________________________
More information about the New-bugs-announce
mailing list