@@ -759,6 +759,11 @@ sub file_declares_8bit_cte {
759
759
$sender = $repoauthor || $repocommitter || ' ' ;
760
760
}
761
761
762
+ # $sender could be an already sanitized address
763
+ # (e.g. sendemail.from could be manually sanitized by user).
764
+ # But it's a no-op to run sanitize_address on an already sanitized address.
765
+ $sender = sanitize_address($sender );
766
+
762
767
my $prompting = 0;
763
768
if (!@initial_to && !defined $to_cmd ) {
764
769
my $to = ask(" Who should the emails be sent to (if any)? " ,
@@ -1071,10 +1076,9 @@ sub send_message {
1071
1076
if ($cc ne ' ' ) {
1072
1077
$ccline = " \n Cc: $cc " ;
1073
1078
}
1074
- my $sanitized_sender = sanitize_address($sender );
1075
1079
make_message_id() unless defined ($message_id );
1076
1080
1077
- my $header = " From: $sanitized_sender
1081
+ my $header = " From: $sender
1078
1082
To: $to${ccline}
1079
1083
Subject: $subject
1080
1084
Date: $date
@@ -1091,7 +1095,7 @@ sub send_message {
1091
1095
}
1092
1096
1093
1097
my @sendmail_parameters = (' -i' , @recipients );
1094
- my $raw_from = $sanitized_sender ;
1098
+ my $raw_from = $sender ;
1095
1099
if (defined $envelope_sender && $envelope_sender ne " auto" ) {
1096
1100
$raw_from = $envelope_sender ;
1097
1101
}
@@ -1292,8 +1296,9 @@ sub send_message {
1292
1296
}
1293
1297
elsif (/ ^From:\s +(.*)$ /i ) {
1294
1298
($author , $author_encoding ) = unquote_rfc2047($1 );
1299
+ my $sauthor = sanitize_address($author );
1295
1300
next if $suppress_cc {' author' };
1296
- next if $suppress_cc {' self' } and $author eq $sender ;
1301
+ next if $suppress_cc {' self' } and $sauthor eq $sender ;
1297
1302
printf (" (mbox) Adding cc: %s from line '%s '\n " ,
1298
1303
$1 , $_ ) unless $quiet ;
1299
1304
push @cc , $1 ;
@@ -1307,7 +1312,9 @@ sub send_message {
1307
1312
}
1308
1313
elsif (/ ^Cc:\s +(.*)$ /i ) {
1309
1314
foreach my $addr (parse_address_line($1 )) {
1310
- if (unquote_rfc2047($addr ) eq $sender ) {
1315
+ my $qaddr = unquote_rfc2047($addr );
1316
+ my $saddr = sanitize_address($qaddr );
1317
+ if ($saddr eq $sender ) {
1311
1318
next if ($suppress_cc {' self' });
1312
1319
} else {
1313
1320
next if ($suppress_cc {' cc' });
@@ -1354,7 +1361,8 @@ sub send_message {
1354
1361
chomp ;
1355
1362
my ($what , $c ) = ($1 , $2 );
1356
1363
chomp $c ;
1357
- if ($c eq $sender ) {
1364
+ my $sc = sanitize_address($c );
1365
+ if ($sc eq $sender ) {
1358
1366
next if ($suppress_cc {' self' });
1359
1367
} else {
1360
1368
next if $suppress_cc {' sob' } and $what =~ / Signed-off-by/i ;
@@ -1438,15 +1446,14 @@ sub send_message {
1438
1446
sub recipients_cmd {
1439
1447
my ($prefix , $what , $cmd , $file ) = @_ ;
1440
1448
1441
- my $sanitized_sender = sanitize_address($sender );
1442
1449
my @addresses = ();
1443
1450
open my $fh , " -|" , " $cmd \Q $file \E "
1444
1451
or die " ($prefix ) Could not execute '$cmd '" ;
1445
1452
while (my $address = <$fh >) {
1446
1453
$address =~ s / ^\s *// g ;
1447
1454
$address =~ s /\s *$// g ;
1448
1455
$address = sanitize_address($address );
1449
- next if ($address eq $sanitized_sender and $suppress_cc {' self' });
1456
+ next if ($address eq $sender and $suppress_cc {' self' });
1450
1457
push @addresses , $address ;
1451
1458
printf (" ($prefix ) Adding %s : %s from: '%s '\n " ,
1452
1459
$what , $address , $cmd ) unless $quiet ;
0 commit comments