From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Perches Subject: Re: [RFC PATCH] git-send-email: Validate recipient_cmd (to-cmd, cc-cmd) addresses Date: Wed, 20 Apr 2011 15:45:11 -0700 Message-ID: <1303339511.24766.41.camel@Joe-Laptop> References: <20110419215239.GA22632@elie> <1303268630.24766.9.camel@Joe-Laptop> <1303336253.24766.34.camel@Joe-Laptop> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Thiago Farina , Jonathan Nieder , Git Mailing List , Nguyen Thai Ngoc Duy , Stephen Boyd To: =?ISO-8859-1?Q?=C6var_Arnfj=F6r=F0?= Bjarmason X-From: git-owner@vger.kernel.org Thu Apr 21 00:45:24 2011 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QCg9A-00013y-UM for gcvg-git-2@lo.gmane.org; Thu, 21 Apr 2011 00:45:21 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752208Ab1DTWpO convert rfc822-to-quoted-printable (ORCPT ); Wed, 20 Apr 2011 18:45:14 -0400 Received: from mail.perches.com ([173.55.12.10]:4857 "EHLO mail.perches.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751971Ab1DTWpN (ORCPT ); Wed, 20 Apr 2011 18:45:13 -0400 Received: from [192.168.1.162] (unknown [192.168.1.162]) by mail.perches.com (Postfix) with ESMTP id B740724368; Wed, 20 Apr 2011 15:45:08 -0700 (PDT) In-Reply-To: X-Mailer: Evolution 2.32.2 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: On Thu, 2011-04-21 at 00:29 +0200, =C3=86var Arnfj=C3=B6r=C3=B0 Bjarmas= on wrote: > On Wed, Apr 20, 2011 at 23:50, Joe Perches wrote: > > + my ($recipient_name, $recipient_addr) =3D ($recipient =3D~ = /^\s*(.*?)\s*(<[^>]+>)/); > In Perl you can write (<.*?>) instead of (<[^>]+>) Hey =C3=86var. That matches <>. Not a good email address. This is what linux/scripts/get_maintainers.pl uses: sub parse_email { my ($formatted_email) =3D @_; my $name =3D ""; my $address =3D ""; if ($formatted_email =3D~ /^([^<]+)<(.+\@.*)>.*$/) { $name =3D $1; $address =3D $2; } elsif ($formatted_email =3D~ /^\s*<(.+\@\S*)>.*$/) { $address =3D $1; } elsif ($formatted_email =3D~ /^(.+\@\S*).*$/) { $address =3D $1; } $name =3D~ s/^\s+|\s+$//g; $name =3D~ s/^\"|\"$//g; $address =3D~ s/^\s+|\s+$//g; if ($name =3D~ /[^\w \-]/i) { ##has "must quote" chars $name =3D~ s/(? If this program doesn't have some extract_emails_from_string() > function already it probably should. Maybe it does. It currently uses "sanitize_address".