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 michael.thies
Recipients barry, michael.thies, r.david.murray
Date 2018-10-24.11:54:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1540382093.01.0.788709270274.issue35057@psf.upfronthosting.co.za>
In-reply-to
Content
Email header refolding in email._header_value_parser adds additional carriage return symbols to the end of nested parse trees, when used with an EmailPolicy with linesep='\r\n'. This leads to broken email headers when composing an email with a "To:" or "CC:" header having a comma-separated list of recipients with some of them containing non-ASCII characters in their DisplayName.

The bug seems to be caused by the following line (in Python 3.7):
`encoded_part = part.fold(policy=policy)[:-1] # strip nl`
(email/_header_value_parser.py, line 2629)

This line calls part.fold() / _refold_parse_tree() recursively and tries to remove the trailing newline, which is added by the recursive call of _refold_parse_tree(). Unfortunately, it fails to do so, if the length of the policy's line separator sequence does not equal 1. Thus, this line should be corrected to something like
`encoded_part = part.fold(policy=policy)[:-len(policy.linesep)] # strip nl`
History
Date User Action Args
2018-10-24 11:54:53michael.thiessetrecipients: + michael.thies, barry, r.david.murray
2018-10-24 11:54:53michael.thiessetmessageid: <1540382093.01.0.788709270274.issue35057@psf.upfronthosting.co.za>
2018-10-24 11:54:52michael.thieslinkissue35057 messages
2018-10-24 11:54:52michael.thiescreate