1
0
mirror of https://github.com/git/git.git synced 2024-10-18 11:08:10 +02:00

Merge branch 'cb/send-email-sanitize-trailer-addresses'

Address-looking strings found on the trailer are now placed on the
Cc: list after running through sanitize_address by "git send-email".

* cb/send-email-sanitize-trailer-addresses:
  git-send-email: use sanitized address when reading mbox body
This commit is contained in:
Junio C Hamano 2024-07-16 11:18:56 -07:00
commit f4c6a0e275
2 changed files with 45 additions and 2 deletions

@ -1847,9 +1847,9 @@ sub pre_process_file {
$what, $_) unless $quiet;
next;
}
push @cc, $c;
push @cc, $sc;
printf(__("(body) Adding cc: %s from line '%s'\n"),
$c, $_) unless $quiet;
$sc, $_) unless $quiet;
}
}
close $fh;

@ -1299,6 +1299,49 @@ test_expect_success $PREREQ 'utf8 sender is not duplicated' '
test_line_count = 1 msgfrom
'
test_expect_success $PREREQ 'setup expect for cc list' "
cat >expected-cc <<\EOF
!recipient@example.com!
!author@example.com!
!one@example.com!
!os@example.com!
!odd_?=mail@example.com!
!doug@example.com!
!codev@example.com!
!thor.au@example.com!
EOF
"
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>
Cc: Ronnie O${SQ}Sullivan <os@example.com>
Reviewed-by: Füñný Nâmé <odd_?=mail@example.com>
Reported-by: bugger on Jira
Reported-by: Douglas Reporter <doug@example.com> [from Jira profile]
BugID: 12345
Co-developed-by: "C. O. Developer" <codev@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 &&
test_grep "^(body) Adding cc: \"Person, One\" <one@example.com>" actual-show-all-headers &&
test_grep "^(body) Adding cc: Ronnie O${SQ}Sullivan <os@example.com>" actual-show-all-headers &&
test_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 &&
test_grep "^(body) Ignoring Reported-by .* bugger on Jira" actual-show-all-headers &&
test_grep "^(body) Adding cc: Douglas Reporter <doug@example.com>" actual-show-all-headers &&
test_grep ! "12345" actual-show-all-headers &&
test_grep "^(body) Adding cc: \"C. O. Developer\" <codev@example.com>" actual-show-all-headers &&
test_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 &&