[issue34155] email.utils.parseaddr mistakenly parse an email
R. David Murray
report at bugs.python.org
Thu Jul 19 11:18:03 EDT 2018
R. David Murray <rdmurray at bitdance.com> added the comment:
That does appear to be a bug. Note that the new email API handles it correctly:
>>> x = """
... > From: =?utf-8?Q?zq at redacted.com.cn=E3=82=86=E2=86=91=E3=82=86?=
... =?utf-8?Q?=E3=82=83=E3=82=85=E3=81=87=E3=81=BA=E3=81=BD=E3=81=BC"\=E3?=
... =?utf-8?Q?=81=A9=E3=81=A5=E3=81=A2l=E3=81=A0=E3=81=B0=E3=81=A8=E3=81?=
... =?utf-8?Q?=8FKL=E3=81=84=E3=82=8C=E3=82=8B=E3=82=86>KL=E3=82=89JF?=
... <mxvu at redacted2.com>
... """
>>> from email import message_from_string
>>> from email.policy import default
>>> m = message_from_string(x+'\n\ntest', policy=default)
>>> m['from']
'"zq at redacted.com.cnゆ↑ゆ ゃゅぇぺぽぼ\\"\\\\� ��づぢlだばと� �KLいれるゆ>KLらJF" <mxvu at redacted2.com>'
>>> m['from'].addresses[0].addr_spec
'mxvu at redacted2.com'
>>> m['from'].addresses[0].display_name
'zq at redacted.com.cnゆ↑ゆ ゃゅぇぺぽぼ"\\\udce3 \udc81\udca9づぢlだばと\udce3\udc81 \udc8fKLいれるゆ>KLらJF'
I'm not particularly interested myself in fixing parseaddr to handle this case correctly, since it is the legacy API, but if someone else wants to I'll review the patch.
----------
versions: +Python 3.7, Python 3.8 -Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34155>
_______________________________________
More information about the Python-bugs-list
mailing list