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 <szeder@ira.uka.de> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael S. Tsirkin committed
Jun 18, 2013 at 15:49 UTC
4cb46bddeb7d21241f8ac5e46eb3d1cee468ea14
2 files changed
+4
-3
git-send-email.perl
+3
-2
@@ -1258,6 +1258,7 @@ foreach my $t (@files) {
1258
open my $fh, "<", $t or die "can't open file $t";
1259
1260
my $author = undef;
1261
+ my $sauthor = undef;
1262
my $author_encoding;
1263
my $has_content_type;
1264
my $body_encoding;
@@ -1296,7 +1297,7 @@ foreach my $t (@files) {
1297
}
1298
elsif (/^From:\s+(.*)$/i) {
1299
($author, $author_encoding) = unquote_rfc2047($1);
1299
- my $sauthor = sanitize_address($author);
1300
+ $sauthor = sanitize_address($author);
1301
next if $suppress_cc{'author'};
1302
next if $suppress_cc{'self'} and $sauthor eq $sender;
1303
printf("(mbox) Adding cc: %s from line '%s'\n",
@@ -1392,7 +1393,7 @@ foreach my $t (@files) {
1393
$subject = quote_subject($subject, $auto_8bit_encoding);
1394
}
1395
1395
- if (defined $author and $author ne $sender) {
1396
+ if (defined $sauthor and $sauthor ne $sender) {
1397
$message = "From: $author\n\n$message";
1398
if (defined $author_encoding) {
1399
if ($has_content_type) {
t/t9001-send-email.sh
+1
-1
@@ -956,7 +956,7 @@ test_expect_success $PREREQ 'utf8 author is correctly passed on' '
956
grep "^From: Füñný Nâmé <odd_?=mail@example.com>" msgtxt1
957
'
958
959
-test_expect_failure $PREREQ 'utf8 sender is not duplicated' '
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^" &&