Subject: Re: [PATCH v4] git-send-email: Use sanitized address when reading mbox body

From: Junio C Hamano <[email-masked]>
Date: Mon, 01 Jul 2024 11:47:34 -0700

"Csókás, Bence" <[email-masked]> writes:

> Addresses that are mentioned on the trailers in the commit log
> ('Signed-off-by: ' etc.) are added to @cc (unless suppressed),
> passed to the SMTP server. However, these hand-written
> addresses may be malformed (e.g. having unquoted commas and
> other punctuation marks in the display-name part).
>
> The code was already calling `sanitize_address()` for suppression
> purposes, so we just have to use the result ($sc) for adding to @cc.

There is a leap between the description of the status quo and your
conclusion.  "we just have to" becomes valid only after explaining
that sanitize_address turns the address-looking string into valid
addresses (and we do not want to send to malformed addresses--but
that goes without saying).

> Also note that
> `sanitize_address()` does not process the mailbox addresses,
> so it is up to `sendmail` to handle special characters there
> (e.g. there are mailboxes in regular use with '+'-es in them).

I do not quote see the point of this final note.  mailboxes with
'q'es in them are also in regular use, and singling out '+' does not
make much sense in the context of explaining this change.

>     Changes in v4:
>     * t9001: use ${SQ} instead of double quotes
>     * re-worded message again

OK.  The additional recipient address 

> +	Co-developed-by: "C. O. Developer" <[email-masked]>

to contrast with

> +	Signed-off-by: A. U. Thor <[email-masked]>

is a nice touch.  We make sure that, with or without necessary
quoting in the original, we produce the correct result ;-).

Let's mark it for 'next' soonish, with proposed log message
rewritten somewhat.

Thanks.

----- >8 -----
git-send-email: use sanitized address when reading mbox body

Addresses that are mentioned on the trailers in the commit log
messages (e.g., "Reviewed-by") are added to the "Cc:" list by "git
send-email".  These hand-written addresses, however, may be
malformed (e.g., having unquoted "." and other punctutation marks in
the display-name part) and can upset MTA.

The code does use the sanitize_address() helper on these
address-looking strings to turn them into valid addresses, but it is
used only to see if the address should be suppressed.  The original
string taken from the message is added to the @cc list if the code
decides the address is not suppressed.

Because the addresses on trailer lines are hand-written and more
likely to contain malformed addresses, when adding to the @cc list,
use the result from sanitize_address, not the original.  Note that
we do not modify the behaviour for addresses taken from the e-mail
headers, as they are more likely to be machine generated and
well-formed.

Signed-off-by: Csókás, Bence <[email-masked]>
Signed-off-by: Junio C Hamano <[email-masked]>