[PATCH 5/9] Perform correct quoting of recipient names.
From: Robin H. Johnson <hidden>
Date: 2016-06-15 22:43:07
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Robin H. Johnson <redacted> 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 <redacted> --- git-send-email.perl | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 5210a40..c052760 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++);
@@ -442,11 +455,7 @@ sub send_message $gitversion = Git::version(); } - 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 $cc = join(", ", unique_email_list(@cc)); my $ccline = ""; if ($cc ne '') {
--
1.5.2.rc0.43.g2f4c7