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 andrei.avk
Recipients andrei.avk, barry, mglover, r.david.murray
Date 2021-07-03.00:29:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1625272159.72.0.816104649038.issue43493@roundup.psfhosted.org>
In-reply-to
Content
I've looked into this and it seems to be somewhat intentional, as can be seen in this test case for example:

test_headerregistry.py", line 1725, in test_fold_address_list
+ To: "Theodore H. Perfect" <yes@man.com>,
+  "My address is very long because my name is long" <foo@bar.com>,
+  "Only A. Friend" <no@yes.com>

Relevant code is here: https://github.com/python/cpython/blob/main/Lib/email/_header_value_parser.py#L2829-L2849

The logic goes like this:
tstr = header value
 - try to add it to current line, if fits; continue to start of loop
 - try to add it to next line, if fits; continue to start of loop
 - split tstr; continue to start of loop

So as you can see from test case, if split happened before step 2, the name would be split over 2 lines which is not ideal.

I tested splitting before step 2, which fixed this bug but failed 11 test cases, all of which deal with email address folding. (To and From headers).

So, is this actually an issue worth fixing?

If the answer is yes, one option would be to special case Subject header and split it before going to step 2.

IOW, the block that starts here: https://github.com/python/cpython/blob/4bcef2bb48b3fd82011a89c1c716421b789f1442/Lib/email/_header_value_parser.py#L2835

would need to be moved after the next block that starts 6 lines below.
History
Date User Action Args
2021-07-03 00:29:19andrei.avksetrecipients: + andrei.avk, barry, r.david.murray, mglover
2021-07-03 00:29:19andrei.avksetmessageid: <1625272159.72.0.816104649038.issue43493@roundup.psfhosted.org>
2021-07-03 00:29:19andrei.avklinkissue43493 messages
2021-07-03 00:29:19andrei.avkcreate