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

6 messages, 4 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:55:22

Felipe Contreras [off-list ref] writes:
On Mon, Nov 19, 2012 at 11:58 PM, Krzysztof Mazur [off-list ref] wrote:
quoted
--- 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
[off-list ref] <#comment>' gets the second comment removed.
Yeah, but do you need to capture the second group?  IOW, like
"s/(.*?>).*$/$1/" perhaps?

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

From: Krzysztof Mazur <hidden>
Date: 2016-06-15 22:55:22

On Mon, Nov 19, 2012 at 03:57:36PM -0800, Junio C Hamano wrote:
Felipe Contreras [off-list ref] writes:
quoted
On Mon, Nov 19, 2012 at 11:58 PM, Krzysztof Mazur [off-list ref] wrote:
quoted
--- 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
[off-list ref] <#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 >" <redacted> #v3.4 v3.5 v3.6

What about:

	$recipient =~ s/(.*<[^@]*@[^]]*>).*$/$1/;

or even
diff --git a/git-send-email.perl b/git-send-email.perl
index 9840d0a..b988c57 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*(<.*)/);
which uses regex used by 99% accurate version of extract_valid_address().

Krzysiek

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

From: Krzysztof Mazur <hidden>
Date: 2016-06-15 22:55:22

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:
quoted
Felipe Contreras [off-list ref] writes:
quoted
On Mon, Nov 19, 2012 at 11:58 PM, Krzysztof Mazur [off-list ref] wrote:
quoted
--- 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
[off-list ref] <#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 >" <redacted> #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

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

From: Felipe Contreras <hidden>
Date: 2016-06-15 22:55:22

On Tue, Nov 20, 2012 at 8:56 AM, Krzysztof Mazur [off-list ref] wrote:
quoted hunk
--- 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/;
I don't think all that extra complexity is warranted, to me
s/(.*?>)(.*)$/$1/ is just fine.

Cheers.

-- 
Felipe Contreras

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

From: Andreas Ericsson <hidden>
Date: 2016-06-15 22:55:22

On 11/20/2012 11:28 AM, Felipe Contreras wrote:
On Tue, Nov 20, 2012 at 8:56 AM, Krzysztof Mazur [off-list ref] wrote:
quoted
--- 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/;
I don't think all that extra complexity is warranted, to me
s/(.*?>)(.*)$/$1/ is just fine.
It's intentionally left without the at-sign so one can send mail to a
local account as well as remote ones. Very nifty when debugging, and
when one wants to preview outgoing emails.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.

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

From: Krzysztof Mazur <hidden>
Date: 2016-06-15 22:55:22

On Tue, Nov 20, 2012 at 11:28:39AM +0100, Felipe Contreras wrote:
On Tue, Nov 20, 2012 at 8:56 AM, Krzysztof Mazur [off-list ref] wrote:
quoted
--- 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/;
I don't think all that extra complexity is warranted, to me
s/(.*?>)(.*)$/$1/ is just fine.
Yeah, it's a little bit too complex, but "s/(.*?>)(.*)$/$1/"
causes small regression - '>' character is no longer allowed
in "phrase" before "<email address>". Maybe the initial version,
that removes everything after last '>' is better? In this case '>'
is not allowed in garbage after email.

Krzysiek
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help