Skip to content

Commit 4cb46bd

Browse files
mstsirkingitster
authored andcommitted
send-email: sanitize author when writing From line
sender is now sanitized, but we didn't sanitize author when checking whether From: line is needed in the message body. As a result git started writing duplicate From: lines when author matched sender and has utf8 characters. Reported-by: SZEDER Gábor <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Tested-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f07075c commit 4cb46bd

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

git-send-email.perl

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

12601260
my $author = undef;
1261+
my $sauthor = undef;
12611262
my $author_encoding;
12621263
my $has_content_type;
12631264
my $body_encoding;
@@ -1296,7 +1297,7 @@ sub send_message {
12961297
}
12971298
elsif (/^From:\s+(.*)$/i) {
12981299
($author, $author_encoding) = unquote_rfc2047($1);
1299-
my $sauthor = sanitize_address($author);
1300+
$sauthor = sanitize_address($author);
13001301
next if $suppress_cc{'author'};
13011302
next if $suppress_cc{'self'} and $sauthor eq $sender;
13021303
printf("(mbox) Adding cc: %s from line '%s'\n",
@@ -1392,7 +1393,7 @@ sub send_message {
13921393
$subject = quote_subject($subject, $auto_8bit_encoding);
13931394
}
13941395

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

t/t9001-send-email.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ 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_failure $PREREQ 'utf8 sender is not duplicated' '
959+
test_expect_success $PREREQ 'utf8 sender is not duplicated' '
960960
clean_fake_sendmail &&
961961
test_commit weird_sender &&
962962
test_when_finished "git reset --hard HEAD^" &&

0 commit comments

Comments
 (0)