rfc822_string() tracked '(' and ')' purely as comment-nesting depth
and only consulted MustQuoteChars once commentlev == 0 and the
character had fallen through every other check. Since '(' and ')'
were handled by their own dedicated branches first, they never
reached the MustQuoteChars check at all, even though both characters
are part of the compiled-in default MustQuoteChars ("@,;:\()[]").
As a result, a full name (e.g. from GECOS, or passed via -F) with
*balanced* parens, such as "LDA CaFE (DW) Service User Admin", was
reported as RFC822-compliant and placed in the From: header
completely unquoted. Per RFC 5322 3.2.2/3.2.3, unquoted parenthesized
text in this position is CFWS (a comment) that any compliant parser
is entitled to treat as non-semantic and discard when re-serializing
the header -- confirmed against a real relay chain (sendmail ->
Postfix -> Exchange Online), where the parenthesized text was
silently dropped. Setting confMUST_QUOTE_CHARS does not help, since
'(' and ')' are intercepted by the comment-tracking branches before
that option is ever consulted.
Move the MustQuoteChars check so it runs before '(' and ')' are
special-cased for comment-nesting, while still only firing at
commentlev == 0 so legitimate nested comments are unaffected.
This issue has also been reported upstream to sendmail.org
(sendmail-bugs-2026@support.sendmail.org).
PR: 253759
MFC after: 1 week