[issue40359] email.parse part.get_filename() fails to unwrap long attachment file names (legacy API)

R. David Murray report at bugs.python.org
Thu Apr 23 10:33:02 EDT 2020


R. David Murray <rdmurray at bitdance.com> added the comment:

Yeah, that looks like a bug in the old API.  If you try the new API, it does the right thing.  To do that, import email.policy and make your message_as_string call:

  email.message_from_string(raw, policy=email.policy.default)

Note, however, that you really ought to be using message_from_bytes.  Serialized email messages are bytes, not unicode, and using message_from_string will get you in to other trouble.

I don't know if it is worth fixing the old API.

----------
title: email.parse part.get_filename() fails to unwrap long attachment file names -> email.parse part.get_filename() fails to unwrap long attachment file names (legacy API)

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40359>
_______________________________________


More information about the Python-bugs-list mailing list