git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Robin H\. Johnson" <robbat2@gentoo.org>
To: git@vger.kernel.org
Cc: Junio C Hamano <junkio@cox.net>,
	"Robin H\. Johnson" <robbat2@gentoo.org>
Subject: [PATCH 5/9] Perform correct quoting of recipient names.
Date: Wed, 25 Apr 2007 19:37:19 -0700	[thread overview]
Message-ID: <11775550432746-git-send-email-robbat2@gentoo.org> (raw)
In-Reply-To: <11775550433288-git-send-email-robbat2@gentoo.org>

From: Robin H. Johnson <robbat2@gentoo.org>

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>
---
 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

  reply	other threads:[~2007-04-26  2:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-26  2:37 git-send-email fixes, cleanups and improvements Robin H. Johnson
2007-04-26  2:37 ` [PATCH 1/9] Document --dry-run parameter to send-email Robin H. Johnson
2007-04-26  2:37   ` [PATCH 2/9] Prefix Dry- to the message status to denote dry-runs Robin H. Johnson
2007-04-26  2:37     ` [PATCH 3/9] Debugging cleanup improvements Robin H. Johnson
2007-04-26  2:37       ` [PATCH 4/9] Change the scope of the $cc variable as it is not needed outside of send_message Robin H. Johnson
2007-04-26  2:37         ` Robin H. Johnson [this message]
2007-04-26  2:37           ` [PATCH 6/9] Validate @recipients before using it for sendmail and Net::SMTP Robin H. Johnson
2007-04-26  2:37             ` [PATCH 7/9] Ensure clean addresses are always used with Net::SMTP Robin H. Johnson
2007-04-26  2:37               ` [PATCH 8/9] Allow users to optionally specify their envelope sender Robin H. Johnson
2007-04-26  2:37                 ` [PATCH 9/9] Document --dry-run and envelope-sender for git-send-email Robin H. Johnson
2007-04-26  4:15           ` [PATCH 5/9] Perform correct quoting of recipient names Junio C Hamano
2007-04-26  4:41             ` Robin H. Johnson
2007-04-26  4:53               ` [PATCH 10/9] Sanitize @to recipients Robin H. Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11775550432746-git-send-email-robbat2@gentoo.org \
    --to=robbat2@gentoo.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).