On Tue, Nov 20, 2012 at 08:31:00AM +0100, Krzysztof Mazur wrote: > On Mon, Nov 19, 2012 at 03:57:36PM -0800, Junio C Hamano wrote: > > Felipe Contreras <felipe.contreras@xxxxxxxxx> writes: > > > > > On Mon, Nov 19, 2012 at 11:58 PM, Krzysztof Mazur <krzysiek@xxxxxxxxxxxx> 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@xxxxxxx> <#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@xxxxxxxxxxxxxxx> #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 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html