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

Re: Failure to extra stable@vger.kernel.org addresses

From
KMKrzysztof Mazur <krzysiek@podlesie.net>
Date
Nov 20, 2012, 07:56 UTC
Message-ID
<20121120075628.GA7159@shrek.podlesie.net>
In-Reply-To
<20121120073100.GB7206@shrek.podlesie.net>
On Tue, Nov 20, 2012 at 08:31:00AM +0100, Krzysztof Mazur wrote:
Show 35 quoted lines
> On Mon, Nov 19, 2012 at 03:57:36PM -0800, Junio C Hamano wrote:
> > Felipe Contreras <felipe.contreras@gmail.com> writes:
> > 
> > > On Mon, Nov 19, 2012 at 11:58 PM, Krzysztof Mazur <krzysiek@podlesie.net> wrote:
> > >
> > >> --- a/git-send-email.perl
> > >> +++ b/git-send-email.perl
> > >> @@ -924,6 +924,10 @@ sub quote_subject {
> > >>  # use the simplest quoting being able to handle the recipient
> > >>  sub sanitize_address {
> > >>         my ($recipient) = @_;
> > >> +
> > >> +       # remove garbage after email address
> > >> +       $recipient =~ s/(.*>).*$/$1/;
> > >> +
> > >
> > > Looks fine, but I would do s/(.*?>)(.*)$/$1/, so that 'test
> > > <foo@bar.com> <#comment>' gets the second comment removed.
> > 
> > Yeah, but do you need to capture the second group?  IOW, like
> > "s/(.*?>).*$/$1/" perhaps?
> 
> I also thought about removing everything after first ">", but I will
> not work for addresses like:
> 
> Cc: "foo >" <stable@vger.kernel.org> #v3.4 v3.5 v3.6
> 
> What about:
> 
> 	$recipient =~ s/(.*<[^@]*@[^]]*>).*$/$1/;
> 
> or even
> 
> which uses regex used by 99% accurate version of extract_valid_address().
> 

Of course, as you suggested earier, only the first email address should be used, so in both cases the first ".*" should be changed to ".*?". The second version becomes:

diff --git a/git-send-email.perl b/git-send-email.perl
index 9840d0a..dbe520c 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -925,8 +925,11 @@ sub quote_subject {
 sub sanitize_address {
 	my ($recipient) = @_;
 
+	my $local_part_regexp = qr/[^<>"\s@]+/;
+	my $domain_regexp = qr/[^.<>"\s@]+(?:\.[^.<>"\s@]+)+/;
+
 	# remove garbage after email address
-	$recipient =~ s/(.*>).*$/$1/;
+	$recipient =~ s/^(.*?<$local_part_regexp\@$domain_regexp>).*/$1/;
 
 	my ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)\s*(<.*)/);
 
Krzysiek
Previous: Krzysztof MazurNext: Felipe Contreras
Message 10 of 34 in “Failure to extra stable@vger.kernel.org addresses”
  1. Felipe BalbiNov 19, 2012
  2. Krzysztof MazurNov 19, 2012
  3. Felipe BalbiNov 19, 2012
  4. Junio C HamanoNov 19, 2012
  5. Felipe ContrerasNov 19, 2012
  6. Krzysztof MazurNov 19, 2012
  7. Felipe ContrerasNov 19, 2012
  8. Junio C HamanoNov 19, 2012
  9. Krzysztof MazurNov 20, 2012
  10. Krzysztof MazurNov 20, 2012
  11. Felipe ContrerasNov 20, 2012
  12. Andreas EricssonNov 20, 2012
  13. Krzysztof MazurNov 20, 2012
  14. Andreas SchwabNov 20, 2012
  15. Krzysztof MazurNov 20, 2012
  16. Felipe ContrerasNov 20, 2012
  17. Junio C HamanoNov 20, 2012
  18. Krzysztof MazurNov 20, 2012
  19. Junio C HamanoNov 20, 2012
  20. 1/5 git-send-email: remove garbage after email addressKrzysztof Mazur, Nov 22, 2012
  21. 2/5 git-send-email: fix fallback code in extract_valid_address()Krzysztof Mazur, Nov 22, 2012
  22. 3/5 git-send-email: remove invalid addresses earlierKrzysztof Mazur, Nov 22, 2012
  23. Junio C HamanoNov 26, 2012
  24. 4/5 git-send-email: ask what to do with an invalid email addressKrzysztof Mazur, Nov 22, 2012
  25. 5/5 git-send-email: allow edit invalid email addressKrzysztof Mazur, Nov 22, 2012
  26. Junio C HamanoNov 26, 2012
  27. Krzysztof MazurNov 26, 2012
  28. Junio C HamanoNov 26, 2012
  29. Krzysztof MazurNov 26, 2012
  30. Junio C HamanoNov 26, 2012
  31. Krzysztof MazurNov 27, 2012
  32. Junio C HamanoNov 20, 2012
  33. Krzysztof MazurNov 20, 2012
  34. Felipe BalbiNov 20, 2012

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.