Perform correct quoting of recipient names.
Always perform quoting of the recipient names if they contain periods, previously only the author's address was treated this way. This stops sendmail binaries from exploding the name into bad addresses. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Robin H. Johnson committed
Apr 25, 2007 at 19:37 UTC
732263d411fe2e3e29ee9fa1c2ad1a20bdea062c
1 file changed
+14
-5
git-send-email.perl
+14
-5
@@ -431,9 +431,22 @@ sub unquote_rfc2047 {
431
return "$_";
432
}
433
434
+# If an address contains a . in the name portion, the name must be quoted.
435
+sub sanitize_address_rfc822
436
+{
437
+ my ($recipient) = @_;
438
+ my ($recipient_name) = ($recipient =~ /^(.*?)\s+</);
439
+ if ($recipient_name && $recipient_name =~ /\./ && $recipient_name !~ /^".*"$/) {
440
+ my ($name, $addr) = ($recipient =~ /^(.*?)(\s+<.*)/);
441
+ $recipient = "\"$name\"$addr";
442
+ }
443
+ return $recipient;
444
+}
445
+
446
sub send_message
447
{
448
my @recipients = unique_email_list(@to);
449
+ @cc = (map { sanitize_address_rfc822($_) } @cc);
450
my $to = join (",\n\t", @recipients);
451
@recipients = unique_email_list(@recipients,@cc,@bcclist);
452
my $date = format_2822_time($time++);
@@ -443,11 +456,7 @@ sub send_message
456
}
457
458
my $cc = join(", ", unique_email_list(@cc));
446
-my ($author_name) = ($from =~ /^(.*?)\s+</);
447
- if ($author_name && $author_name =~ /\./ && $author_name !~ /^".*"$/) {
448
- my ($name, $addr) = ($from =~ /^(.*?)(\s+<.*)/);
449
- $from = "\"$name\"$addr";
450
- }
459
+ $from = sanitize_address_rfc822($from);
460
my $header = "From: $from
461
To: $to
462
Cc: $cc