summaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2007-04-25 19:37:19 -0700
committerJunio C Hamano <junkio@cox.net>2007-04-25 21:11:15 -0700
commit732263d411fe2e3e29ee9fa1c2ad1a20bdea062c (patch)
tree3ac30345854f6c9948dbdb2ad77683c4c42847da /git-send-email.perl
parentaf068d274245be9aedc58e6835c2e43329639974 (diff)
downloadgit-732263d411fe2e3e29ee9fa1c2ad1a20bdea062c.tar.gz
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>
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl19
1 files changed, 14 insertions, 5 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index ad83009e23..e4fe8965bb 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -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++);
@@ -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