From: Joe Perches <joe@perches.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Thiago Farina <tfransosi@gmail.com>,
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: Re: [RFC PATCH] git-send-email: Validate recipient_cmd (to-cmd, cc-cmd) addresses
Date: Wed, 20 Apr 2011 15:45:11 -0700 [thread overview]
Message-ID: <1303339511.24766.41.camel@Joe-Laptop> (raw)
In-Reply-To: <BANLkTikuC1V1U-c0wyThOZAn6gVXr7S_cQ@mail.gmail.com>
On Thu, 2011-04-21 at 00:29 +0200, Ævar Arnfjörð Bjarmason wrote:
> On Wed, Apr 20, 2011 at 23:50, Joe Perches <joe@perches.com> wrote:
> > + my ($recipient_name, $recipient_addr) = ($recipient =~ /^\s*(.*?)\s*(<[^>]+>)/);
> In Perl you can write (<.*?>) instead of (<[^>]+>)
Hey Ævar. That matches <>. Not a good email address.
This is what linux/scripts/get_maintainers.pl uses:
sub parse_email {
my ($formatted_email) = @_;
my $name = "";
my $address = "";
if ($formatted_email =~ /^([^<]+)<(.+\@.*)>.*$/) {
$name = $1;
$address = $2;
} elsif ($formatted_email =~ /^\s*<(.+\@\S*)>.*$/) {
$address = $1;
} elsif ($formatted_email =~ /^(.+\@\S*).*$/) {
$address = $1;
}
$name =~ s/^\s+|\s+$//g;
$name =~ s/^\"|\"$//g;
$address =~ s/^\s+|\s+$//g;
if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
$name =~ s/(?<!\\)"/\\"/g; ##escape quotes
$name = "\"$name\"";
}
return ($name, $address);
}
There's probably some weakness in that.
> If this program doesn't have some extract_emails_from_string()
> function already it probably should.
Maybe it does. It currently uses "sanitize_address".
next prev parent reply other threads:[~2011-04-20 22:45 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 ` [RFC PATCH] git-send-email: Validate recipient_cmd (to-cmd, cc-cmd) addresses Joe Perches
2011-04-20 22:29 ` Ævar Arnfjörð Bjarmason
2011-04-20 22:45 ` Joe Perches [this message]
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=1303339511.24766.41.camel@Joe-Laptop \
--to=joe@perches.com \
--cc=avarab@gmail.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 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).