Skip to content

Commit b29dc5c

Browse files
committed
Merge branch 'mt/send-email-cc-match-fix'
Logic used by git-send-email to suppress cc mishandled names that need RFC2047 quoting. * mt/send-email-cc-match-fix: send-email: sanitize author when writing From line send-email: add test for duplicate utf8 name
2 parents 833cd7f + 4cb46bd commit b29dc5c

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

git-send-email.perl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,7 @@ sub send_message {
12591259
open my $fh, "<", $t or die "can't open file $t";
12601260

12611261
my $author = undef;
1262+
my $sauthor = undef;
12621263
my $author_encoding;
12631264
my $has_content_type;
12641265
my $body_encoding;
@@ -1297,7 +1298,7 @@ sub send_message {
12971298
}
12981299
elsif (/^From:\s+(.*)$/i) {
12991300
($author, $author_encoding) = unquote_rfc2047($1);
1300-
my $sauthor = sanitize_address($author);
1301+
$sauthor = sanitize_address($author);
13011302
next if $suppress_cc{'author'};
13021303
next if $suppress_cc{'self'} and $sauthor eq $sender;
13031304
printf("(mbox) Adding cc: %s from line '%s'\n",
@@ -1393,7 +1394,7 @@ sub send_message {
13931394
$subject = quote_subject($subject, $auto_8bit_encoding);
13941395
}
13951396

1396-
if (defined $author and $author ne $sender) {
1397+
if (defined $sauthor and $sauthor ne $sender) {
13971398
$message = "From: $author\n\n$message";
13981399
if (defined $author_encoding) {
13991400
if ($has_content_type) {

t/t9001-send-email.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,20 @@ test_expect_success $PREREQ 'utf8 author is correctly passed on' '
956956
grep "^From: Füñný Nâmé <[email protected]>" msgtxt1
957957
'
958958

959+
test_expect_success $PREREQ 'utf8 sender is not duplicated' '
960+
clean_fake_sendmail &&
961+
test_commit weird_sender &&
962+
test_when_finished "git reset --hard HEAD^" &&
963+
git commit --amend --author "Füñný Nâmé <[email protected]>" &&
964+
git format-patch --stdout -1 >funny_name.patch &&
965+
git send-email --from="Füñný Nâmé <[email protected]>" \
966+
967+
--smtp-server="$(pwd)/fake.sendmail" \
968+
funny_name.patch &&
969+
grep "^From: " msgtxt1 >msgfrom &&
970+
test_line_count = 1 msgfrom
971+
'
972+
959973
test_expect_success $PREREQ 'sendemail.composeencoding works' '
960974
clean_fake_sendmail &&
961975
git config sendemail.composeencoding iso-8859-1 &&

0 commit comments

Comments
 (0)