Skip to content

Commit

Permalink
Perform correct quoting of recipient names.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
robbat2 authored and Junio C Hamano committed Apr 26, 2007
1 parent af068d2 commit 732263d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,22 @@ sub unquote_rfc2047 {
return "$_";
}

# If an address contains a . in the name portion, the name must be quoted.
sub sanitize_address_rfc822
{
my ($recipient) = @_;
my ($recipient_name) = ($recipient =~ /^(.*?)\s+</);
if ($recipient_name && $recipient_name =~ /\./ && $recipient_name !~ /^".*"$/) {
my ($name, $addr) = ($recipient =~ /^(.*?)(\s+<.*)/);
$recipient = "\"$name\"$addr";
}
return $recipient;
}

sub send_message
{
my @recipients = unique_email_list(@to);
@cc = (map { sanitize_address_rfc822($_) } @cc);
my $to = join (",\n\t", @recipients);
@recipients = unique_email_list(@recipients,@cc,@bcclist);
my $date = format_2822_time($time++);
Expand All @@ -443,11 +456,7 @@ sub send_message
}

my $cc = join(", ", unique_email_list(@cc));
my ($author_name) = ($from =~ /^(.*?)\s+</);
if ($author_name && $author_name =~ /\./ && $author_name !~ /^".*"$/) {
my ($name, $addr) = ($from =~ /^(.*?)(\s+<.*)/);
$from = "\"$name\"$addr";
}
$from = sanitize_address_rfc822($from);
my $header = "From: $from
To: $to
Cc: $cc
Expand Down

0 comments on commit 732263d

Please sign in to comment.