On 5/14/20 7:44 PM, Alan So wrote:
I just notice that if I send an email to a list with a Cc header broken into multiple lines and the pair of double quotes are put in different lines, the email addresses afterwards will be wrongly rewritten.
For example,
CC: "ABC DEF (XYZ)" <name@example.com>
tl;dr It is not valid to fold a header inside of a quotes string.
First of all, the above is invalid. Presumably the address is intended to be
"ABC DEF (XYZ)" <name@example.com>
RFC 5322, sec 2.2.3 says in part:
"The general rule is that wherever this specification allows for folding white space (not simply WSP characters), a CRLF may be inserted before any WSP."
and the definitions in sec 3.4 say in part:
address = mailbox / group
mailbox = name-addr / addr-spec
name-addr = [display-name] angle-addr
angle-addr = [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr
display-name = phrase
In this case, the quoted-string "ABC DEF (XYZ)" is a phrase which is the display-name and the only places where comments or folding white space are allowed is immediately preceding the "<" or following the ">" surrounding the addr-spec. Folding in the middle of the quoted string is not allowed.
Were there no quotes, e.g.
ABC DEF (XYZ) <name@example.com>
Then ABC DEF is a phrase and (XYZ) is a comment and folding between DEF and (XYZ) would be allowed
It will become the following after going through the mailing list:
CC: XYZ <"ABC DEF"@mail.server.name>
Which is clearly wrong, but GIGO.
It seems that Outlook often split the To/Cc header into multiple lines and they often add double quotes to the full name of the users. Is the rewriting of Cc header handled by Mailman's code or another Python class?
I haven't looked at the code to see exactly what's responsible here. I do note that adding double quotes around a display name is not only allowed, but is required if the display name contains "specials".
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan