From: Joe Perches <joe@perches.com>
To: Thiago Farina <tfransosi@gmail.com>
Cc: Jonathan Nieder <jrnieder@gmail.com>,
Git Mailing List <git@vger.kernel.org>,
Nguyen Thai Ngoc Duy <pclouds@gmail.com>,
Stephen Boyd <bebarino@gmail.com>
Subject: [RFC PATCH] git-send-email: Validate recipient_cmd (to-cmd, cc-cmd) addresses
Date: Wed, 20 Apr 2011 14:50:53 -0700 [thread overview]
Message-ID: <1303336253.24766.34.camel@Joe-Laptop> (raw)
In-Reply-To: <BANLkTinfbF3xyfrdgfmgHQF7RHCHk8ardw@mail.gmail.com>
On Wed, 2011-04-20 at 12:45 -0300, Thiago Farina wrote:
> On Wed, Apr 20, 2011 at 12:03 AM, Joe Perches <joe@perches.com> wrote:
> > On Tue, 2011-04-19 at 16:52 -0500, Jonathan Nieder wrote:
> >> Thiago Farina wrote:
> >> > when I run:
> >> > $ git send-email --to linux-kernel@vger.kernel.org --cc-cmd
> >> > scripts/get_maintainer.pl foo
> >> > I'm getting some lines like:
> >> > Use of uninitialized value $cc in string eq at
> >> > /home/tfarina/libexec/git-core/git-send-email line 964.
> >> Yes, sounds like a bug. Cc-ing some send-email people for tips.
Perhaps some patch like this.
Validate the address(es) returned from recipient_cmd.
Die if the output contains an invalid address.
Signed-off-by: Joe Perches <joe@perches.com>
---
git-send-email.perl | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 76565de..9273cf2 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -870,10 +870,14 @@ sub is_rfc2047_quoted {
# use the simplest quoting being able to handle the recipient
sub sanitize_address {
my ($recipient) = @_;
- my ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)\s*(<.*)/);
+ my ($recipient_name, $recipient_addr) = ($recipient =~ /^\s*(.*?)\s*(<[^>]+>)/);
if (not $recipient_name) {
- return $recipient;
+ return $recipient_addr if ($recipient_addr);
+ if ($recipient =~ /^\s*(.+\@\S*).*$/) {
+ return $1;
+ }
+ return "";
}
# if recipient_name is already quoted, do nothing
@@ -1343,11 +1347,13 @@ sub recipients_cmd {
while (my $address = <$fh>) {
$address =~ s/^\s*//g;
$address =~ s/\s*$//g;
- $address = sanitize_address($address);
- next if ($address eq $sanitized_sender and $suppress_from);
- push @addresses, $address;
+ my $sanitized_address = sanitize_address($address);
+ next if ($sanitized_address eq $sanitized_sender and $suppress_from);
+ die "($prefix) '$cmd' returned invalid address: '$address'\n"
+ if ($address =~ /.*${sanitized_address}.+/);
+ push @addresses, $sanitized_address;
printf("($prefix) Adding %s: %s from: '%s'\n",
- $what, $address, $cmd) unless $quiet;
+ $what, $sanitized_address, $cmd) unless $quiet;
}
close $fh
or die "($prefix) failed to close pipe to '$cmd'";
next prev parent reply other threads:[~2011-04-20 21:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-17 22:32 problem when using --cc-cmd Thiago Farina
2011-04-19 21:52 ` Jonathan Nieder
2011-04-20 3:03 ` Joe Perches
2011-04-20 15:45 ` Thiago Farina
2011-04-20 19:48 ` Joe Perches
2011-04-20 21:50 ` Joe Perches [this message]
2011-04-20 22:29 ` [RFC PATCH] git-send-email: Validate recipient_cmd (to-cmd, cc-cmd) addresses Ævar Arnfjörð Bjarmason
2011-04-20 22:45 ` Joe Perches
2011-04-20 22:50 ` Ævar Arnfjörð Bjarmason
2011-04-20 23:01 ` Joe Perches
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=1303336253.24766.34.camel@Joe-Laptop \
--to=joe@perches.com \
--cc=bebarino@gmail.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=pclouds@gmail.com \
--cc=tfransosi@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.