This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Emil.Styrke
Recipients Emil.Styrke
Date 2021-03-19.09:45:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1616147102.5.0.601004900737.issue43554@roundup.psfhosted.org>
In-reply-to
Content
When a header with an encoded (QP or Base64) display_name is refolded, it may lose (some of) its encoding.  If it then contains illegal "atext" tokens, an invalid header will result.

For example, `From: =?utf-8?Q?a=2C=20123456789012345678901234567890123456?= <abc@example.com>` will become `From: a, 123456789012345678901234567890123456 <abc@example.com>`  This contains a comma character which needs to be quoted: correct rendering would be `From: "a, 123456789012345678901234567890123456" <abc@example.com>`. Note that this example isn't even folded to multiple lines, since the decoded text is short enough to fit in one line.

This can be triggered by `BytesParser(policy=policy.default).parsebytes("From: =?utf-8?Q?a=2C=20123456789012345678901234567890123456?= <abc@example.com>").as_bytes()`, but the offending code seems to be in or below `email.policy.EmailPolicy.fold`.  See attached file for examples with and without folding.
History
Date User Action Args
2021-03-19 09:45:02Emil.Styrkesetrecipients: + Emil.Styrke
2021-03-19 09:45:02Emil.Styrkesetmessageid: <1616147102.5.0.601004900737.issue43554@roundup.psfhosted.org>
2021-03-19 09:45:02Emil.Styrkelinkissue43554 messages
2021-03-19 09:45:02Emil.Styrkecreate