git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-send-email.perl extract_valid_address issue

From
Horst von Brand <vonbrand@inf.utfsm.cl>
Date
May 29, 2006, 21:06 UTC
Message-ID
<200605292106.k4TL6L4o014248@laptop11.inf.utfsm.cl>
In-Reply-To
<ryan@michonline.com>
Ryan Anderson <ryan@michonline.com> wrote:
Show 39 quoted lines
> On Mon, May 29, 2006 at 12:00:44AM -0400, Nicolas Troncoso Carrere wrote:
> > 
> > The third fallback was returning if the match was done or not instead of
> > returning the actual email address that was matched. This prevented sending
> > the mail to the people included in the CC. This bug only affect those that
> > dont have Email::Valid.
> > 
> > I initialized $valid_email as undef so it would mimic the behavior of 
> > Email::Verify->address(), which returns undef if no valid address was found.
> 
> Odd, I noticed the same thing this weekend.
> 
> > Signed-off-by: Nicolas <ntroncos@inf.utfsm.cl>
> Acked-by: Ryan Anderson <ryan@michonline.com>
> 
> (Or pick up my patch that fixes this in a slightly different way)
> 
> > 
> > 
> > ---
> > 
> >  git-send-email.perl |    4 +++-
> >  1 files changed, 3 insertions(+), 1 deletions(-)
> > 
> > 84853ca89c15de7a24e9eb9fd422654b86c63be9
> > diff --git a/git-send-email.perl b/git-send-email.perl
> > index 312a4ea..dfff3e6 100755
> > --- a/git-send-email.perl
> > +++ b/git-send-email.perl
> > @@ -316,7 +316,9 @@ sub extract_valid_address {
> >  	} else {
> >  		# less robust/correct than the monster regexp in Email::Valid,
> >  		# but still does a 99% job, and one less dependency
> > -		return ($address =~ /([^\"<>\s]+@[^<>\s]+)/);
> > +                my $valid_email=undef;
> > +                ($valid_email ) = ($address =~ /([^\"<>\s]+@[^<>\s]+)/);
> > +                return ($valid_email);
> >  	}
> >  }

I just looked it over, and this is certainly broken in the original. The first return gives the string back if it matches, the second one evaluates the list returned by the match in scalar context, and so returns 1 for a match or 0 for non-match. Besides, the regexps are fishy...

- The first one won't consider 'Joe.Hacker' as a valid local address
- The second one will consider 'Joe.Hacker@example.com"' valid (note ")

Need to make both branches (with and without @) agree here, at least. And this is certainly severely underpowered... dunno if it merits a better job (or just bail out if Email::Valid isn't found, instead of kludgeing around...)

Will propose a fix ASAP.
-- 
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
Previous: Daniel BarkalowNext: Horst von Brand
Message 17 of 19 in “Re: Git 1.0 Synopis (Draft v3”
  1. Horst von BrandJul 31, 2005
  2. Git 1.0 Synopis (Draft v4)Ryan Anderson, Aug 15, 2005
  3. Ryan AndersonAug 15, 2005
  4. Junio C HamanoAug 15, 2005
  5. Ryan AndersonAug 15, 2005
  6. Junio C HamanoAug 15, 2005
  7. Ryan AndersonAug 15, 2005
  8. Junio C HamanoAug 15, 2005
  9. Daniel BarkalowAug 15, 2005
  10. Junio C HamanoAug 16, 2005
  11. Johannes SchindelinAug 16, 2005
  12. Dongsheng SongAug 16, 2005
  13. about git server & permissionsDongsheng Song, Aug 16, 2005
  14. Johannes SchindelinAug 16, 2005
  15. Daniel BarkalowAug 16, 2005
  16. Daniel BarkalowAug 16, 2005
  17. Horst von BrandMay 29, 2006
  18. Horst von BrandMay 29, 2006
  19. Eric WongMay 29, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.