git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v2 0/6] git send-email suppress-cc=self fixes
@ 2013-05-30  7:11 Michael S. Tsirkin
  2013-05-30  7:11 ` [PATCH v2 1/6] t/send-email.sh: add test for suppress-cc=self Michael S. Tsirkin
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Michael S. Tsirkin @ 2013-05-30  7:11 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

This includes bugfixes related to handling of --suppress-cc=self
flag. Tests are also included.

Changes from v1:
	- tweak coding style in tests to address comments by Junio

Michael S. Tsirkin (6):
  t/send-email.sh: add test for suppress-cc=self
  send-email: fix suppress-cc=self on cccmd
  t/send-email: test suppress-cc=self on cccmd
  send-email: make --suppress-cc=self sanitize input
  t/send-email: add test with quoted sender
  t/send-email: test suppress-cc=self with non-ascii

 git-send-email.perl   | 20 +++++++++------
 t/t9001-send-email.sh | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+), 8 deletions(-)

-- 
MST

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 1/6] t/send-email.sh: add test for suppress-cc=self
  2013-05-30  7:11 [PATCH v2 0/6] git send-email suppress-cc=self fixes Michael S. Tsirkin
@ 2013-05-30  7:11 ` Michael S. Tsirkin
  2013-06-03 16:19   ` Junio C Hamano
  2013-05-30  7:11 ` [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd Michael S. Tsirkin
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Michael S. Tsirkin @ 2013-05-30  7:11 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

This adds a basic test for --suppress-cc=self
option of git send-email.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 t/t9001-send-email.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index ebd5c5d..e1a7f3e 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -171,6 +171,49 @@ Result: OK
 EOF
 "
 
+test_suppress_self () {
+	test_commit $3 &&
+	test_when_finished "git reset --hard HEAD^" &&
+
+	write_script cccmd-sed <<-EOF &&
+		sed -n -e s/^cccmd--//p "\$1"
+	EOF
+
+	git commit --amend --author="$1 <$2>" -F - &&  
+	clean_fake_sendmail &&  
+	git format-patch --stdout -1 >"suppress-self-$3.patch" &&  
+
+	git send-email --from="$1 <$2>" \
+		--to=nobody@example.com \
+		--cc-cmd=./cccmd-sed \
+		--suppress-cc=self \
+		--smtp-server="$(pwd)/fake.sendmail" \
+		suppress-self-$3.patch &&
+
+	mv msgtxt1 msgtxt1-$3 &&
+	sed -e '/^$/q' msgtxt1-$3 >"msghdr1-$3" &&
+	>"expected-no-cc-$3" &&
+
+	(grep '^Cc:' msghdr1-$3 >"actual-no-cc-$3";
+	 test_cmp expected-no-cc-$3 actual-no-cc-$3)
+}
+
+test_suppress_self_unquoted () {
+	test_suppress_self "$1" "$2" "unquoted-$3" <<-EOF
+		test suppress-cc.self unquoted-$3 with name $1 email $2
+
+		unquoted-$3
+
+		Cc: $1 <$2>
+		Signed-off-by: $1 <$2>
+	EOF
+}
+
+test_expect_success $PREREQ 'self name is suppressed' "
+	test_suppress_self_unquoted 'A U Thor' 'author@redhat.com' \
+		'self_name_suppressed'
+"
+
 test_expect_success $PREREQ 'Show all headers' '
 	git send-email \
 		--dry-run \
-- 
MST

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd
  2013-05-30  7:11 [PATCH v2 0/6] git send-email suppress-cc=self fixes Michael S. Tsirkin
  2013-05-30  7:11 ` [PATCH v2 1/6] t/send-email.sh: add test for suppress-cc=self Michael S. Tsirkin
@ 2013-05-30  7:11 ` Michael S. Tsirkin
  2013-06-03 15:58   ` Junio C Hamano
  2013-05-30  7:11 ` [PATCH v2 3/6] t/send-email: test " Michael S. Tsirkin
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Michael S. Tsirkin @ 2013-05-30  7:11 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

When cccmd is used, old-style suppress-from filter
is applied by the newer suppress-cc=self isn't.
Fix this up.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 git-send-email.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index bd13cc8..a138615 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1462,7 +1462,7 @@ sub recipients_cmd {
 		$address =~ s/^\s*//g;
 		$address =~ s/\s*$//g;
 		$address = sanitize_address($address);
-		next if ($address eq $sanitized_sender and $suppress_from);
+		next if ($address eq $sender and $suppress_cc{'self'});
 		push @addresses, $address;
 		printf("($prefix) Adding %s: %s from: '%s'\n",
 		       $what, $address, $cmd) unless $quiet;
-- 
MST

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 3/6] t/send-email: test suppress-cc=self on cccmd
  2013-05-30  7:11 [PATCH v2 0/6] git send-email suppress-cc=self fixes Michael S. Tsirkin
  2013-05-30  7:11 ` [PATCH v2 1/6] t/send-email.sh: add test for suppress-cc=self Michael S. Tsirkin
  2013-05-30  7:11 ` [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd Michael S. Tsirkin
@ 2013-05-30  7:11 ` Michael S. Tsirkin
  2013-05-30  7:11 ` [PATCH v2 4/6] send-email: make --suppress-cc=self sanitize input Michael S. Tsirkin
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 18+ messages in thread
From: Michael S. Tsirkin @ 2013-05-30  7:11 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Check that suppress-cc=self works when applied
to output of cccmd.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 t/t9001-send-email.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index e1a7f3e..452b362 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -204,6 +204,8 @@ test_suppress_self_unquoted () {
 
 		unquoted-$3
 
+		cccmd--$1 <$2>
+
 		Cc: $1 <$2>
 		Signed-off-by: $1 <$2>
 	EOF
-- 
MST

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 4/6] send-email: make --suppress-cc=self sanitize input
  2013-05-30  7:11 [PATCH v2 0/6] git send-email suppress-cc=self fixes Michael S. Tsirkin
                   ` (2 preceding siblings ...)
  2013-05-30  7:11 ` [PATCH v2 3/6] t/send-email: test " Michael S. Tsirkin
@ 2013-05-30  7:11 ` Michael S. Tsirkin
  2013-06-03 16:17   ` Junio C Hamano
  2013-05-30  7:11 ` [PATCH v2 5/6] t/send-email: add test with quoted sender Michael S. Tsirkin
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Michael S. Tsirkin @ 2013-05-30  7:11 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

--suppress-cc=self fails to filter sender address in many cases where it
needs to be sanitized in some way, for example quoted:
"A U. Thor" <author@example.com>
To fix, make send-email sanitize both sender and the address it is
compared against.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 git-send-email.perl | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/git-send-email.perl b/git-send-email.perl
index a138615..92df393 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -760,6 +760,8 @@ if (!defined $sender) {
 	$sender = $repoauthor || $repocommitter || '';
 }
 
+$sender = sanitize_address($sender);
+
 my $prompting = 0;
 if (!@initial_to && !defined $to_cmd) {
 	my $to = ask("Who should the emails be sent to (if any)? ",
@@ -1113,10 +1115,9 @@ sub send_message {
 	if ($cc ne '') {
 		$ccline = "\nCc: $cc";
 	}
-	my $sanitized_sender = sanitize_address($sender);
 	make_message_id() unless defined($message_id);
 
-	my $header = "From: $sanitized_sender
+	my $header = "From: $sender
 To: $to${ccline}
 Subject: $subject
 Date: $date
@@ -1133,7 +1134,7 @@ X-Mailer: git-send-email $gitversion
 	}
 
 	my @sendmail_parameters = ('-i', @recipients);
-	my $raw_from = $sanitized_sender;
+	my $raw_from = $sender;
 	if (defined $envelope_sender && $envelope_sender ne "auto") {
 		$raw_from = $envelope_sender;
 	}
@@ -1308,8 +1309,9 @@ foreach my $t (@files) {
 			}
 			elsif (/^From:\s+(.*)$/i) {
 				($author, $author_encoding) = unquote_rfc2047($1);
+				my $sauthor = sanitize_address($author);
 				next if $suppress_cc{'author'};
-				next if $suppress_cc{'self'} and $author eq $sender;
+				next if $suppress_cc{'self'} and $sauthor eq $sender;
 				printf("(mbox) Adding cc: %s from line '%s'\n",
 					$1, $_) unless $quiet;
 				push @cc, $1;
@@ -1323,7 +1325,9 @@ foreach my $t (@files) {
 			}
 			elsif (/^Cc:\s+(.*)$/i) {
 				foreach my $addr (parse_address_line($1)) {
-					if (unquote_rfc2047($addr) eq $sender) {
+					my $qaddr = unquote_rfc2047($addr);
+					my $saddr = sanitize_address($qaddr);
+					if ($saddr eq $sender) {
 						next if ($suppress_cc{'self'});
 					} else {
 						next if ($suppress_cc{'cc'});
@@ -1370,7 +1374,8 @@ foreach my $t (@files) {
 			chomp;
 			my ($what, $c) = ($1, $2);
 			chomp $c;
-			if ($c eq $sender) {
+			my $sc = sanitize_address($c);
+			if ($sc eq $sender) {
 				next if ($suppress_cc{'self'});
 			} else {
 				next if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;
@@ -1454,7 +1459,6 @@ foreach my $t (@files) {
 sub recipients_cmd {
 	my ($prefix, $what, $cmd, $file) = @_;
 
-	my $sanitized_sender = sanitize_address($sender);
 	my @addresses = ();
 	open my $fh, "-|", "$cmd \Q$file\E"
 	    or die "($prefix) Could not execute '$cmd'";
-- 
MST

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 5/6] t/send-email: add test with quoted sender
  2013-05-30  7:11 [PATCH v2 0/6] git send-email suppress-cc=self fixes Michael S. Tsirkin
                   ` (3 preceding siblings ...)
  2013-05-30  7:11 ` [PATCH v2 4/6] send-email: make --suppress-cc=self sanitize input Michael S. Tsirkin
@ 2013-05-30  7:11 ` Michael S. Tsirkin
  2013-05-30  7:11 ` [PATCH v2 6/6] t/send-email: test suppress-cc=self with non-ascii Michael S. Tsirkin
  2013-06-03 16:18 ` [PATCH v2 0/6] git send-email suppress-cc=self fixes Junio C Hamano
  6 siblings, 0 replies; 18+ messages in thread
From: Michael S. Tsirkin @ 2013-05-30  7:11 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

add test where sender address needs to be quoted.
Make sure --suppress-cc=self works well in this case.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 t/t9001-send-email.sh | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 452b362..42fb809 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -211,11 +211,31 @@ test_suppress_self_unquoted () {
 	EOF
 }
 
+test_suppress_self_quoted () {
+	test_suppress_self "$1" "$2" "quoted-$3" <<-EOF
+		test suppress-cc.self quoted-$3 with name $1 email $2
+
+		quoted-$3
+
+		cccmd--"$1" <$2>
+
+		Cc: $1 <$2>
+		Cc: "$1" <$2>
+		Signed-off-by: $1 <$2>
+		Signed-off-by: "$1" <$2>
+	EOF
+}
+
 test_expect_success $PREREQ 'self name is suppressed' "
 	test_suppress_self_unquoted 'A U Thor' 'author@redhat.com' \
 		'self_name_suppressed'
 "
 
+test_expect_success $PREREQ 'quoted self name is suppressed' "
+	test_suppress_self_quoted 'A U. Thor' 'author@redhat.com' \
+		'self_name_suppressed'
+"
+
 test_expect_success $PREREQ 'Show all headers' '
 	git send-email \
 		--dry-run \
-- 
MST

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH v2 6/6] t/send-email: test suppress-cc=self with non-ascii
  2013-05-30  7:11 [PATCH v2 0/6] git send-email suppress-cc=self fixes Michael S. Tsirkin
                   ` (4 preceding siblings ...)
  2013-05-30  7:11 ` [PATCH v2 5/6] t/send-email: add test with quoted sender Michael S. Tsirkin
@ 2013-05-30  7:11 ` Michael S. Tsirkin
  2013-06-03 16:18 ` [PATCH v2 0/6] git send-email suppress-cc=self fixes Junio C Hamano
  6 siblings, 0 replies; 18+ messages in thread
From: Michael S. Tsirkin @ 2013-05-30  7:11 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

test suppress-cc=self when sender is non-acsii

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 t/t9001-send-email.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 42fb809..430e8de 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -236,6 +236,11 @@ test_expect_success $PREREQ 'quoted self name is suppressed' "
 		'self_name_suppressed'
 "
 
+test_expect_success $PREREQ 'non-ascii self name is suppressed' "
+	test_suppress_self_quoted 'Füñný Nâmé' 'odd_?=mail@example.com' \
+		'non_ascii_self_suppressed'
+"
+
 test_expect_success $PREREQ 'Show all headers' '
 	git send-email \
 		--dry-run \
-- 
MST

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd
  2013-05-30  7:11 ` [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd Michael S. Tsirkin
@ 2013-06-03 15:58   ` Junio C Hamano
  2013-06-03 16:15     ` Michael S. Tsirkin
  0 siblings, 1 reply; 18+ messages in thread
From: Junio C Hamano @ 2013-06-03 15:58 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: git

"Michael S. Tsirkin" <mst@redhat.com> writes:

> When cccmd is used, old-style suppress-from filter
> is applied by the newer suppress-cc=self isn't.
> Fix this up.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  git-send-email.perl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/git-send-email.perl b/git-send-email.perl
> index bd13cc8..a138615 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -1462,7 +1462,7 @@ sub recipients_cmd {
>  		$address =~ s/^\s*//g;
>  		$address =~ s/\s*$//g;
>  		$address = sanitize_address($address);
> -		next if ($address eq $sanitized_sender and $suppress_from);
> +		next if ($address eq $sender and $suppress_cc{'self'});

If $suppress_from is defined, $suppress_cc{'self'} gets its value,
so the latter half of this change is very understandable.

The original comparison uses $address that is "sanitized" (whose
definition is roughly "mangled/quoted with rfc2047 etc to fit on
To/Cc headers") against $sanitized_sender, which means for a

    $sender = 'Michael S. Tsirkin <mst@redhat.com>';

we used

    $sanitized_sender = '"Michael S. Tsirkin" <mst@redhat.com>';

for comparison, but the new code does not quote the $recipient_name
part inside dq for the single dot after the middle name.  Is this a
desirable change?

>  		push @addresses, $address;
>  		printf("($prefix) Adding %s: %s from: '%s'\n",
>  		       $what, $address, $cmd) unless $quiet;

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd
  2013-06-03 15:58   ` Junio C Hamano
@ 2013-06-03 16:15     ` Michael S. Tsirkin
  2013-06-03 18:04       ` Junio C Hamano
  0 siblings, 1 reply; 18+ messages in thread
From: Michael S. Tsirkin @ 2013-06-03 16:15 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Mon, Jun 03, 2013 at 08:58:14AM -0700, Junio C Hamano wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
> 
> > When cccmd is used, old-style suppress-from filter
> > is applied by the newer suppress-cc=self isn't.
> > Fix this up.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >  git-send-email.perl | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/git-send-email.perl b/git-send-email.perl
> > index bd13cc8..a138615 100755
> > --- a/git-send-email.perl
> > +++ b/git-send-email.perl
> > @@ -1462,7 +1462,7 @@ sub recipients_cmd {
> >  		$address =~ s/^\s*//g;
> >  		$address =~ s/\s*$//g;
> >  		$address = sanitize_address($address);
> > -		next if ($address eq $sanitized_sender and $suppress_from);
> > +		next if ($address eq $sender and $suppress_cc{'self'});
> 
> If $suppress_from is defined, $suppress_cc{'self'} gets its value,
> so the latter half of this change is very understandable.
> 
> The original comparison uses $address that is "sanitized" (whose
> definition is roughly "mangled/quoted with rfc2047 etc to fit on
> To/Cc headers") against $sanitized_sender, which means for a
> 
>     $sender = 'Michael S. Tsirkin <mst@redhat.com>';
> 
> we used
> 
>     $sanitized_sender = '"Michael S. Tsirkin" <mst@redhat.com>';
> 
> for comparison, but the new code does not quote the $recipient_name
> part inside dq for the single dot after the middle name.  Is this a
> desirable change?

What I tried to do here is split the changes to small
chunks and I picked a chunk of a later patch in an earlier one
by mistake.

So this is fixed up by patch 4/6
in the series, which redefines sender to have
the sanitized value, everywhere.

I guess I'll have to repost moving this former
chunk to patch 4.


> >  		push @addresses, $address;
> >  		printf("($prefix) Adding %s: %s from: '%s'\n",
> >  		       $what, $address, $cmd) unless $quiet;

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 4/6] send-email: make --suppress-cc=self sanitize input
  2013-05-30  7:11 ` [PATCH v2 4/6] send-email: make --suppress-cc=self sanitize input Michael S. Tsirkin
@ 2013-06-03 16:17   ` Junio C Hamano
  2013-06-03 16:32     ` Michael S. Tsirkin
  0 siblings, 1 reply; 18+ messages in thread
From: Junio C Hamano @ 2013-06-03 16:17 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: git

"Michael S. Tsirkin" <mst@redhat.com> writes:

> --suppress-cc=self fails to filter sender address in many cases where it
> needs to be sanitized in some way, for example quoted:
> "A U. Thor" <author@example.com>
> To fix, make send-email sanitize both sender and the address it is
> compared against.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---

OK, so you are getting rid of distinctions between sanitized_sender
and sender, and $sender is now defined to be always "sanitized"
form.

That change makes things consistent with respect to the question I
had on [2/6].

I however wondered how this would affect those who have configured
"sendemail.from" with an already "sanitized" address.  That is, you
may have used:

	[sendemail]
        	from = "Michael S. Tsirkin" <mst@redhat.com>

with the older and current versions of Git.  I _think_ the safetly
of this change relies on that it is a no-op to run sanitize_address
on an already sanitized address (i.e. feeding the above example
sendemail.from to sanitize_address gives back the same string),
which holds true for all practical purposes, but it is a bit subtle.

>  git-send-email.perl | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/git-send-email.perl b/git-send-email.perl
> index a138615..92df393 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -760,6 +760,8 @@ if (!defined $sender) {
>  	$sender = $repoauthor || $repocommitter || '';
>  }
>  
> +$sender = sanitize_address($sender);
> +
>  my $prompting = 0;
>  if (!@initial_to && !defined $to_cmd) {
>  	my $to = ask("Who should the emails be sent to (if any)? ",
> @@ -1113,10 +1115,9 @@ sub send_message {
>  	if ($cc ne '') {
>  		$ccline = "\nCc: $cc";
>  	}
> -	my $sanitized_sender = sanitize_address($sender);
>  	make_message_id() unless defined($message_id);
>  
> -	my $header = "From: $sanitized_sender
> +	my $header = "From: $sender
>  To: $to${ccline}
>  Subject: $subject
>  Date: $date
> @@ -1133,7 +1134,7 @@ X-Mailer: git-send-email $gitversion
>  	}
>  
>  	my @sendmail_parameters = ('-i', @recipients);
> -	my $raw_from = $sanitized_sender;
> +	my $raw_from = $sender;
>  	if (defined $envelope_sender && $envelope_sender ne "auto") {
>  		$raw_from = $envelope_sender;
>  	}
> @@ -1308,8 +1309,9 @@ foreach my $t (@files) {
>  			}
>  			elsif (/^From:\s+(.*)$/i) {
>  				($author, $author_encoding) = unquote_rfc2047($1);
> +				my $sauthor = sanitize_address($author);
>  				next if $suppress_cc{'author'};
> -				next if $suppress_cc{'self'} and $author eq $sender;
> +				next if $suppress_cc{'self'} and $sauthor eq $sender;
>  				printf("(mbox) Adding cc: %s from line '%s'\n",
>  					$1, $_) unless $quiet;
>  				push @cc, $1;
> @@ -1323,7 +1325,9 @@ foreach my $t (@files) {
>  			}
>  			elsif (/^Cc:\s+(.*)$/i) {
>  				foreach my $addr (parse_address_line($1)) {
> -					if (unquote_rfc2047($addr) eq $sender) {
> +					my $qaddr = unquote_rfc2047($addr);
> +					my $saddr = sanitize_address($qaddr);
> +					if ($saddr eq $sender) {
>  						next if ($suppress_cc{'self'});
>  					} else {
>  						next if ($suppress_cc{'cc'});
> @@ -1370,7 +1374,8 @@ foreach my $t (@files) {
>  			chomp;
>  			my ($what, $c) = ($1, $2);
>  			chomp $c;
> -			if ($c eq $sender) {
> +			my $sc = sanitize_address($c);
> +			if ($sc eq $sender) {
>  				next if ($suppress_cc{'self'});
>  			} else {
>  				next if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;
> @@ -1454,7 +1459,6 @@ foreach my $t (@files) {
>  sub recipients_cmd {
>  	my ($prefix, $what, $cmd, $file) = @_;
>  
> -	my $sanitized_sender = sanitize_address($sender);
>  	my @addresses = ();
>  	open my $fh, "-|", "$cmd \Q$file\E"
>  	    or die "($prefix) Could not execute '$cmd'";

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 0/6] git send-email suppress-cc=self fixes
  2013-05-30  7:11 [PATCH v2 0/6] git send-email suppress-cc=self fixes Michael S. Tsirkin
                   ` (5 preceding siblings ...)
  2013-05-30  7:11 ` [PATCH v2 6/6] t/send-email: test suppress-cc=self with non-ascii Michael S. Tsirkin
@ 2013-06-03 16:18 ` Junio C Hamano
  2013-06-03 16:36   ` Michael S. Tsirkin
  6 siblings, 1 reply; 18+ messages in thread
From: Junio C Hamano @ 2013-06-03 16:18 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: git

"Michael S. Tsirkin" <mst@redhat.com> writes:

> This includes bugfixes related to handling of --suppress-cc=self
> flag. Tests are also included.

Thanks, will queue.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 1/6] t/send-email.sh: add test for suppress-cc=self
  2013-05-30  7:11 ` [PATCH v2 1/6] t/send-email.sh: add test for suppress-cc=self Michael S. Tsirkin
@ 2013-06-03 16:19   ` Junio C Hamano
  0 siblings, 0 replies; 18+ messages in thread
From: Junio C Hamano @ 2013-06-03 16:19 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: git

"Michael S. Tsirkin" <mst@redhat.com> writes:

> This adds a basic test for --suppress-cc=self
> option of git send-email.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  t/t9001-send-email.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
>
> diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
> index ebd5c5d..e1a7f3e 100755
> --- a/t/t9001-send-email.sh
> +++ b/t/t9001-send-email.sh
> @@ -171,6 +171,49 @@ Result: OK
>  EOF
>  "
>  
> +test_suppress_self () {
> +	test_commit $3 &&
> +	test_when_finished "git reset --hard HEAD^" &&
> +
> +	write_script cccmd-sed <<-EOF &&
> +		sed -n -e s/^cccmd--//p "\$1"
> +	EOF
> +
> +	git commit --amend --author="$1 <$2>" -F - &&  

Ahh, this helper reads the log message from its standard input;
nice.

> +	clean_fake_sendmail &&  
> +	git format-patch --stdout -1 >"suppress-self-$3.patch" &&  
> +
> +	git send-email --from="$1 <$2>" \
> +		--to=nobody@example.com \
> +		--cc-cmd=./cccmd-sed \
> +		--suppress-cc=self \
> +		--smtp-server="$(pwd)/fake.sendmail" \
> +		suppress-self-$3.patch &&
> +
> +	mv msgtxt1 msgtxt1-$3 &&
> +	sed -e '/^$/q' msgtxt1-$3 >"msghdr1-$3" &&
> +	>"expected-no-cc-$3" &&
> +
> +	(grep '^Cc:' msghdr1-$3 >"actual-no-cc-$3";
> +	 test_cmp expected-no-cc-$3 actual-no-cc-$3)
> +}
> +
> +test_suppress_self_unquoted () {
> +	test_suppress_self "$1" "$2" "unquoted-$3" <<-EOF
> +		test suppress-cc.self unquoted-$3 with name $1 email $2
> +
> +		unquoted-$3
> +
> +		Cc: $1 <$2>
> +		Signed-off-by: $1 <$2>
> +	EOF
> +}
> +
> +test_expect_success $PREREQ 'self name is suppressed' "
> +	test_suppress_self_unquoted 'A U Thor' 'author@redhat.com' \
> +		'self_name_suppressed'
> +"
> +
>  test_expect_success $PREREQ 'Show all headers' '
>  	git send-email \
>  		--dry-run \

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 4/6] send-email: make --suppress-cc=self sanitize input
  2013-06-03 16:17   ` Junio C Hamano
@ 2013-06-03 16:32     ` Michael S. Tsirkin
  2013-06-03 18:02       ` Junio C Hamano
  0 siblings, 1 reply; 18+ messages in thread
From: Michael S. Tsirkin @ 2013-06-03 16:32 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Mon, Jun 03, 2013 at 09:17:21AM -0700, Junio C Hamano wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
> 
> > --suppress-cc=self fails to filter sender address in many cases where it
> > needs to be sanitized in some way, for example quoted:
> > "A U. Thor" <author@example.com>
> > To fix, make send-email sanitize both sender and the address it is
> > compared against.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> 
> OK, so you are getting rid of distinctions between sanitized_sender
> and sender, and $sender is now defined to be always "sanitized"
> form.
> 
> That change makes things consistent with respect to the question I
> had on [2/6].
> 
> I however wondered how this would affect those who have configured
> "sendemail.from" with an already "sanitized" address.  That is, you
> may have used:
> 
> 	[sendemail]
>         	from = "Michael S. Tsirkin" <mst@redhat.com>
> 
> with the older and current versions of Git.  I _think_ the safetly
> of this change relies on that it is a no-op to run sanitize_address
> on an already sanitized address (i.e. feeding the above example
> sendemail.from to sanitize_address gives back the same string),
> which holds true for all practical purposes, but it is a bit subtle.

Yes, I think so too. So - what do you suggest?
	Add a test?
	Add a comment?
more?

> >  git-send-email.perl | 18 +++++++++++-------
> >  1 file changed, 11 insertions(+), 7 deletions(-)
> >
> > diff --git a/git-send-email.perl b/git-send-email.perl
> > index a138615..92df393 100755
> > --- a/git-send-email.perl
> > +++ b/git-send-email.perl
> > @@ -760,6 +760,8 @@ if (!defined $sender) {
> >  	$sender = $repoauthor || $repocommitter || '';
> >  }
> >  
> > +$sender = sanitize_address($sender);
> > +
> >  my $prompting = 0;
> >  if (!@initial_to && !defined $to_cmd) {
> >  	my $to = ask("Who should the emails be sent to (if any)? ",
> > @@ -1113,10 +1115,9 @@ sub send_message {
> >  	if ($cc ne '') {
> >  		$ccline = "\nCc: $cc";
> >  	}
> > -	my $sanitized_sender = sanitize_address($sender);
> >  	make_message_id() unless defined($message_id);
> >  
> > -	my $header = "From: $sanitized_sender
> > +	my $header = "From: $sender
> >  To: $to${ccline}
> >  Subject: $subject
> >  Date: $date
> > @@ -1133,7 +1134,7 @@ X-Mailer: git-send-email $gitversion
> >  	}
> >  
> >  	my @sendmail_parameters = ('-i', @recipients);
> > -	my $raw_from = $sanitized_sender;
> > +	my $raw_from = $sender;
> >  	if (defined $envelope_sender && $envelope_sender ne "auto") {
> >  		$raw_from = $envelope_sender;
> >  	}
> > @@ -1308,8 +1309,9 @@ foreach my $t (@files) {
> >  			}
> >  			elsif (/^From:\s+(.*)$/i) {
> >  				($author, $author_encoding) = unquote_rfc2047($1);
> > +				my $sauthor = sanitize_address($author);
> >  				next if $suppress_cc{'author'};
> > -				next if $suppress_cc{'self'} and $author eq $sender;
> > +				next if $suppress_cc{'self'} and $sauthor eq $sender;
> >  				printf("(mbox) Adding cc: %s from line '%s'\n",
> >  					$1, $_) unless $quiet;
> >  				push @cc, $1;
> > @@ -1323,7 +1325,9 @@ foreach my $t (@files) {
> >  			}
> >  			elsif (/^Cc:\s+(.*)$/i) {
> >  				foreach my $addr (parse_address_line($1)) {
> > -					if (unquote_rfc2047($addr) eq $sender) {
> > +					my $qaddr = unquote_rfc2047($addr);
> > +					my $saddr = sanitize_address($qaddr);
> > +					if ($saddr eq $sender) {
> >  						next if ($suppress_cc{'self'});
> >  					} else {
> >  						next if ($suppress_cc{'cc'});
> > @@ -1370,7 +1374,8 @@ foreach my $t (@files) {
> >  			chomp;
> >  			my ($what, $c) = ($1, $2);
> >  			chomp $c;
> > -			if ($c eq $sender) {
> > +			my $sc = sanitize_address($c);
> > +			if ($sc eq $sender) {
> >  				next if ($suppress_cc{'self'});
> >  			} else {
> >  				next if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;
> > @@ -1454,7 +1459,6 @@ foreach my $t (@files) {
> >  sub recipients_cmd {
> >  	my ($prefix, $what, $cmd, $file) = @_;
> >  
> > -	my $sanitized_sender = sanitize_address($sender);
> >  	my @addresses = ();
> >  	open my $fh, "-|", "$cmd \Q$file\E"
> >  	    or die "($prefix) Could not execute '$cmd'";

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 0/6] git send-email suppress-cc=self fixes
  2013-06-03 16:18 ` [PATCH v2 0/6] git send-email suppress-cc=self fixes Junio C Hamano
@ 2013-06-03 16:36   ` Michael S. Tsirkin
  0 siblings, 0 replies; 18+ messages in thread
From: Michael S. Tsirkin @ 2013-06-03 16:36 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Mon, Jun 03, 2013 at 09:18:56AM -0700, Junio C Hamano wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
> 
> > This includes bugfixes related to handling of --suppress-cc=self
> > flag. Tests are also included.
> 
> Thanks, will queue.

OK pls let me know if this means you intend to handle the rest of your
comments yourself or if I need to fix anything.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 4/6] send-email: make --suppress-cc=self sanitize input
  2013-06-03 16:32     ` Michael S. Tsirkin
@ 2013-06-03 18:02       ` Junio C Hamano
  0 siblings, 0 replies; 18+ messages in thread
From: Junio C Hamano @ 2013-06-03 18:02 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: git

"Michael S. Tsirkin" <mst@redhat.com> writes:

> Yes, I think so too. So - what do you suggest?
> 	Add a test?
> 	Add a comment?
> more?

Nothing major comes to my mind at this moment.

I guess it would be good to add a test or two to use "A U. Thor"
example with and without end-user added quotes, but that can be done
as a follow-up patch on top of this series (i.e. [PATCH 7/6]).

Thanks.

>> >  git-send-email.perl | 18 +++++++++++-------
>> >  1 file changed, 11 insertions(+), 7 deletions(-)
>> >
>> > diff --git a/git-send-email.perl b/git-send-email.perl
>> > index a138615..92df393 100755
>> > --- a/git-send-email.perl
>> > +++ b/git-send-email.perl
>> > @@ -760,6 +760,8 @@ if (!defined $sender) {
>> >  	$sender = $repoauthor || $repocommitter || '';
>> >  }
>> >  
>> > +$sender = sanitize_address($sender);
>> > +
>> >  my $prompting = 0;
>> >  if (!@initial_to && !defined $to_cmd) {
>> >  	my $to = ask("Who should the emails be sent to (if any)? ",
>> > @@ -1113,10 +1115,9 @@ sub send_message {
>> >  	if ($cc ne '') {
>> >  		$ccline = "\nCc: $cc";
>> >  	}
>> > -	my $sanitized_sender = sanitize_address($sender);
>> >  	make_message_id() unless defined($message_id);
>> >  
>> > -	my $header = "From: $sanitized_sender
>> > +	my $header = "From: $sender
>> >  To: $to${ccline}
>> >  Subject: $subject
>> >  Date: $date
>> > @@ -1133,7 +1134,7 @@ X-Mailer: git-send-email $gitversion
>> >  	}
>> >  
>> >  	my @sendmail_parameters = ('-i', @recipients);
>> > -	my $raw_from = $sanitized_sender;
>> > +	my $raw_from = $sender;
>> >  	if (defined $envelope_sender && $envelope_sender ne "auto") {
>> >  		$raw_from = $envelope_sender;
>> >  	}
>> > @@ -1308,8 +1309,9 @@ foreach my $t (@files) {
>> >  			}
>> >  			elsif (/^From:\s+(.*)$/i) {
>> >  				($author, $author_encoding) = unquote_rfc2047($1);
>> > +				my $sauthor = sanitize_address($author);
>> >  				next if $suppress_cc{'author'};
>> > -				next if $suppress_cc{'self'} and $author eq $sender;
>> > +				next if $suppress_cc{'self'} and $sauthor eq $sender;
>> >  				printf("(mbox) Adding cc: %s from line '%s'\n",
>> >  					$1, $_) unless $quiet;
>> >  				push @cc, $1;
>> > @@ -1323,7 +1325,9 @@ foreach my $t (@files) {
>> >  			}
>> >  			elsif (/^Cc:\s+(.*)$/i) {
>> >  				foreach my $addr (parse_address_line($1)) {
>> > -					if (unquote_rfc2047($addr) eq $sender) {
>> > +					my $qaddr = unquote_rfc2047($addr);
>> > +					my $saddr = sanitize_address($qaddr);
>> > +					if ($saddr eq $sender) {
>> >  						next if ($suppress_cc{'self'});
>> >  					} else {
>> >  						next if ($suppress_cc{'cc'});
>> > @@ -1370,7 +1374,8 @@ foreach my $t (@files) {
>> >  			chomp;
>> >  			my ($what, $c) = ($1, $2);
>> >  			chomp $c;
>> > -			if ($c eq $sender) {
>> > +			my $sc = sanitize_address($c);
>> > +			if ($sc eq $sender) {
>> >  				next if ($suppress_cc{'self'});
>> >  			} else {
>> >  				next if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;
>> > @@ -1454,7 +1459,6 @@ foreach my $t (@files) {
>> >  sub recipients_cmd {
>> >  	my ($prefix, $what, $cmd, $file) = @_;
>> >  
>> > -	my $sanitized_sender = sanitize_address($sender);
>> >  	my @addresses = ();
>> >  	open my $fh, "-|", "$cmd \Q$file\E"
>> >  	    or die "($prefix) Could not execute '$cmd'";

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd
  2013-06-03 16:15     ` Michael S. Tsirkin
@ 2013-06-03 18:04       ` Junio C Hamano
  2013-06-03 19:58         ` Michael S. Tsirkin
  0 siblings, 1 reply; 18+ messages in thread
From: Junio C Hamano @ 2013-06-03 18:04 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: git

"Michael S. Tsirkin" <mst@redhat.com> writes:

> What I tried to do here is split the changes to small chunks and I
> picked a chunk of a later patch in an earlier one by mistake.
>
> So this is fixed up by patch 4/6 in the series, which redefines
> sender to have the sanitized value, everywhere.
>
> I guess I'll have to repost moving this former chunk to patch 4.

Yeah, that may be a good idea.

Thanks.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd
  2013-06-03 18:04       ` Junio C Hamano
@ 2013-06-03 19:58         ` Michael S. Tsirkin
  2013-06-03 21:55           ` Junio C Hamano
  0 siblings, 1 reply; 18+ messages in thread
From: Michael S. Tsirkin @ 2013-06-03 19:58 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Mon, Jun 03, 2013 at 11:04:31AM -0700, Junio C Hamano wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
> 
> > What I tried to do here is split the changes to small chunks and I
> > picked a chunk of a later patch in an earlier one by mistake.
> >
> > So this is fixed up by patch 4/6 in the series, which redefines
> > sender to have the sanitized value, everywhere.
> >
> > I guess I'll have to repost moving this former chunk to patch 4.
> 
> Yeah, that may be a good idea.
> 
> Thanks.

Or just smash 2+4 together ...
Confused. You are doing this or want me ot?

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd
  2013-06-03 19:58         ` Michael S. Tsirkin
@ 2013-06-03 21:55           ` Junio C Hamano
  0 siblings, 0 replies; 18+ messages in thread
From: Junio C Hamano @ 2013-06-03 21:55 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: git

"Michael S. Tsirkin" <mst@redhat.com> writes:

> On Mon, Jun 03, 2013 at 11:04:31AM -0700, Junio C Hamano wrote:
>> "Michael S. Tsirkin" <mst@redhat.com> writes:
>> 
>> > What I tried to do here is split the changes to small chunks and I
>> > picked a chunk of a later patch in an earlier one by mistake.
>> >
>> > So this is fixed up by patch 4/6 in the series, which redefines
>> > sender to have the sanitized value, everywhere.
>> >
>> > I guess I'll have to repost moving this former chunk to patch 4.
>> 
>> Yeah, that may be a good idea.
>> 
>> Thanks.
>
> Or just smash 2+4 together ...
> Confused. You are doing this or want me ot?

Sorry, I was expecting you would do so, after saying "I'll have to
repost" and I responded "Yeah, good idea".

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2013-06-03 21:55 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-30  7:11 [PATCH v2 0/6] git send-email suppress-cc=self fixes Michael S. Tsirkin
2013-05-30  7:11 ` [PATCH v2 1/6] t/send-email.sh: add test for suppress-cc=self Michael S. Tsirkin
2013-06-03 16:19   ` Junio C Hamano
2013-05-30  7:11 ` [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd Michael S. Tsirkin
2013-06-03 15:58   ` Junio C Hamano
2013-06-03 16:15     ` Michael S. Tsirkin
2013-06-03 18:04       ` Junio C Hamano
2013-06-03 19:58         ` Michael S. Tsirkin
2013-06-03 21:55           ` Junio C Hamano
2013-05-30  7:11 ` [PATCH v2 3/6] t/send-email: test " Michael S. Tsirkin
2013-05-30  7:11 ` [PATCH v2 4/6] send-email: make --suppress-cc=self sanitize input Michael S. Tsirkin
2013-06-03 16:17   ` Junio C Hamano
2013-06-03 16:32     ` Michael S. Tsirkin
2013-06-03 18:02       ` Junio C Hamano
2013-05-30  7:11 ` [PATCH v2 5/6] t/send-email: add test with quoted sender Michael S. Tsirkin
2013-05-30  7:11 ` [PATCH v2 6/6] t/send-email: test suppress-cc=self with non-ascii Michael S. Tsirkin
2013-06-03 16:18 ` [PATCH v2 0/6] git send-email suppress-cc=self fixes Junio C Hamano
2013-06-03 16:36   ` Michael S. Tsirkin

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).