From: Junio C Hamano <gitster@pobox.com>
To: "Csókás, Bence" <csokas.bence@prolan.hu>
Cc: <git@vger.kernel.org>
Subject: Re: [PATCH v2] git-send-email: Use sanitized address when reading mbox body
Date: Wed, 26 Jun 2024 10:28:45 -0700 [thread overview]
Message-ID: <xmqqy16r1ulu.fsf@gitster.g> (raw)
In-Reply-To: <20240626132440.3762363-2-csokas.bence@prolan.hu> ("Csókás, Bence"'s message of "Wed, 26 Jun 2024 15:24:41 +0200")
"Csókás, Bence" <csokas.bence@prolan.hu> writes:
> Commas and other punctuation marks in 'Cc: ', 'Signed-off-by: '
> etc. lines mess with git-send-email. In parsing the mbox headers,
> this is handled by calling `sanitize_address()`. This function
> is called when parsing the message body as well, but was only
> used for comparing it to $author. Now we add it to @cc too.
The above is misleading, though. We do use sanitize_address on
addresses we find on e-mail headers, but the result is not used
in @to or @cc, the addresses we use to actually send the message
out.
Perhaps phrase it more like ...
When we check addresses found on the mbox headers to see if we
want to add them to Cc:, we use sanitize_address() function to
normalize the addresses before passing them to the suppression
mechanism, but we use the original addresses for the purpose of
sending the message out.
We use the same logic on the address-looking strings found on
trailer lines that appear in the message body. Sanitized
addresses are used for Cc-suppression purposes, but the original
addresses as written by the end-user are used as the mail
destination.
There are certain quoting rules for e-mail addresses, and unlike
addresses on e-mail headers that are generated by format-patch,
hand-written addresses on the trailer lines are more likely to
violate them by mistake.
When adding the address found on a trailer line in the message
body, use the sanitized address for both sending the message
out, as well as checking with Cc-suppression mechanism, to
reduce the risk of malformed hand-written addresses to get the
message rejected (but keep using the original addresses found on
the e-mail headers in the input message for e-mail destination).
... or something like that?
> diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
> index 58699f8e4e..7e0b8ae57c 100755
> --- a/t/t9001-send-email.sh
> +++ b/t/t9001-send-email.sh
This test uses mixture of test_grep and grep, so use of "grep" below
is fine (but in the longer term we should make sure the tests use
the former for better debuggability).
As I always say, we should resist the temptation to write our tests
just to demonstrate our shiny new toy. In this case, the test is
too focused to show that the system will give a best-effort output
when fed invalid and/or malformed addresses, but it does not see
what happens to a well formed addresses (ideally they are passed
intact, but is that what happens with the new code?). Perhaps add
one or two trailer lines with valid addresses (and non-address, like
"BugId: 143421", that should not appear at all in the output) on
them?
Thanks.
> +test_expect_success $PREREQ 'cc list is sanitized' '
> + clean_fake_sendmail &&
> + test_commit weird_cc_body &&
> + test_when_finished "git reset --hard HEAD^" &&
> + git commit --amend -F - <<-EOF &&
> + Test Cc: sanitization.
> +
> + Cc: Person, One <one@example.com>
> + Reviewed-by: Füñný Nâmé <odd_?=mail@example.com>
> + Signed-off-by: A. U. Thor <thor.au@example.com>
> + EOF
> + git send-email -1 --to=recipient@example.com \
> + --smtp-server="$(pwd)/fake.sendmail" >actual-show-all-headers &&
> + test_cmp expected-cc commandline1 &&
> + grep "^(body) Adding cc: \"Person, One\" <one@example.com>" actual-show-all-headers &&
> + grep "^(body) Adding cc: =?UTF-8?q?F=C3=BC=C3=B1n=C3=BD=20N=C3=A2m=C3=A9?="\
> +" <odd_?=mail@example.com>" actual-show-all-headers &&
> + grep "^(body) Adding cc: \"A. U. Thor\" <thor.au@example.com>" actual-show-all-headers
> +'
> test_expect_success $PREREQ 'sendemail.composeencoding works' '
> clean_fake_sendmail &&
> git config sendemail.composeencoding iso-8859-1 &&
next prev parent reply other threads:[~2024-06-26 17:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 13:24 [PATCH v2] git-send-email: Use sanitized address when reading mbox body Csókás, Bence
2024-06-26 17:28 ` Junio C Hamano [this message]
2024-06-27 8:37 ` Csókás Bence
2024-06-27 15:09 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqy16r1ulu.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=csokas.bence@prolan.hu \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.