{"thread":{"id":"33983","subject":"[PATCH v2 0/6] git send-email suppress-cc=self fixes","startedAt":"2013-05-30T07:11:08Z","lastAt":"2013-06-03T21:55:03Z","messageCount":18,"participants":["Michael S. Tsirkin","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":6},"messages":[{"id":"218945","messageId":"1369897638-27299-1-git-send-email-mst@redhat.com","threadId":"33983","inReplyTo":null,"subject":"[PATCH v2 0/6] git send-email suppress-cc=self fixes","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-05-30T07:11:08Z","receivedAt":"2013-05-30T07:11:08Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"This includes bugfixes related to handling of --suppress-cc=self\nflag. Tests are also included.\n\nChanges from v1:\n\t- tweak coding style in tests to address comments by Junio\n\nMichael S. Tsirkin (6):\n  t/send-email.sh: add test for suppress-cc=self\n  send-email: fix suppress-cc=self on cccmd\n  t/send-email: test suppress-cc=self on cccmd\n  send-email: make --suppress-cc=self sanitize input\n  t/send-email: add test with quoted sender\n  t/send-email: test suppress-cc=self with non-ascii\n\n git-send-email.perl   | 20 +++++++++------\n t/t9001-send-email.sh | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 82 insertions(+), 8 deletions(-)\n\n-- \nMST\n"},{"id":"218946","messageId":"1369897638-27299-2-git-send-email-mst@redhat.com","threadId":"33983","inReplyTo":"1369897638-27299-1-git-send-email-mst@redhat.com","subject":"[PATCH v2 1/6] t/send-email.sh: add test for suppress-cc=self","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-05-30T07:11:13Z","receivedAt":"2013-05-30T07:11:13Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"This adds a basic test for --suppress-cc=self\noption of git send-email.\n\nSigned-off-by: Michael S. Tsirkin <mst@redhat.com>\n---\n t/t9001-send-email.sh | 43 +++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 43 insertions(+)\n\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex ebd5c5d..e1a7f3e 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -171,6 +171,49 @@ Result: OK\n EOF\n \"\n \n+test_suppress_self () {\n+\ttest_commit $3 &&\n+\ttest_when_finished \"git reset --hard HEAD^\" &&\n+\n+\twrite_script cccmd-sed <<-EOF &&\n+\t\tsed -n -e s/^cccmd--//p \"\\$1\"\n+\tEOF\n+\n+\tgit commit --amend --author=\"$1 <$2>\" -F - &&  \n+\tclean_fake_sendmail &&  \n+\tgit format-patch --stdout -1 >\"suppress-self-$3.patch\" &&  \n+\n+\tgit send-email --from=\"$1 <$2>\" \\\n+\t\t--to=nobody@example.com \\\n+\t\t--cc-cmd=./cccmd-sed \\\n+\t\t--suppress-cc=self \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\tsuppress-self-$3.patch &&\n+\n+\tmv msgtxt1 msgtxt1-$3 &&\n+\tsed -e '/^$/q' msgtxt1-$3 >\"msghdr1-$3\" &&\n+\t>\"expected-no-cc-$3\" &&\n+\n+\t(grep '^Cc:' msghdr1-$3 >\"actual-no-cc-$3\";\n+\t test_cmp expected-no-cc-$3 actual-no-cc-$3)\n+}\n+\n+test_suppress_self_unquoted () {\n+\ttest_suppress_self \"$1\" \"$2\" \"unquoted-$3\" <<-EOF\n+\t\ttest suppress-cc.self unquoted-$3 with name $1 email $2\n+\n+\t\tunquoted-$3\n+\n+\t\tCc: $1 <$2>\n+\t\tSigned-off-by: $1 <$2>\n+\tEOF\n+}\n+\n+test_expect_success $PREREQ 'self name is suppressed' \"\n+\ttest_suppress_self_unquoted 'A U Thor' 'author@redhat.com' \\\n+\t\t'self_name_suppressed'\n+\"\n+\n test_expect_success $PREREQ 'Show all headers' '\n \tgit send-email \\\n \t\t--dry-run \\\n-- \nMST\n"},{"id":"218948","messageId":"1369897638-27299-3-git-send-email-mst@redhat.com","threadId":"33983","inReplyTo":"1369897638-27299-1-git-send-email-mst@redhat.com","subject":"[PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-05-30T07:11:15Z","receivedAt":"2013-05-30T07:11:15Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"When cccmd is used, old-style suppress-from filter\nis applied by the newer suppress-cc=self isn't.\nFix this up.\n\nSigned-off-by: Michael S. Tsirkin <mst@redhat.com>\n---\n git-send-email.perl | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex bd13cc8..a138615 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1462,7 +1462,7 @@ sub recipients_cmd {\n \t\t$address =~ s/^\\s*//g;\n \t\t$address =~ s/\\s*$//g;\n \t\t$address = sanitize_address($address);\n-\t\tnext if ($address eq $sanitized_sender and $suppress_from);\n+\t\tnext if ($address eq $sender and $suppress_cc{'self'});\n \t\tpush @addresses, $address;\n \t\tprintf(\"($prefix) Adding %s: %s from: '%s'\\n\",\n \t\t       $what, $address, $cmd) unless $quiet;\n-- \nMST\n"},{"id":"218947","messageId":"1369897638-27299-4-git-send-email-mst@redhat.com","threadId":"33983","inReplyTo":"1369897638-27299-1-git-send-email-mst@redhat.com","subject":"[PATCH v2 3/6] t/send-email: test suppress-cc=self on cccmd","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-05-30T07:11:18Z","receivedAt":"2013-05-30T07:11:18Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"Check that suppress-cc=self works when applied\nto output of cccmd.\n\nSigned-off-by: Michael S. Tsirkin <mst@redhat.com>\n---\n t/t9001-send-email.sh | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex e1a7f3e..452b362 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -204,6 +204,8 @@ test_suppress_self_unquoted () {\n \n \t\tunquoted-$3\n \n+\t\tcccmd--$1 <$2>\n+\n \t\tCc: $1 <$2>\n \t\tSigned-off-by: $1 <$2>\n \tEOF\n-- \nMST\n"},{"id":"218951","messageId":"1369897638-27299-5-git-send-email-mst@redhat.com","threadId":"33983","inReplyTo":"1369897638-27299-1-git-send-email-mst@redhat.com","subject":"[PATCH v2 4/6] send-email: make --suppress-cc=self sanitize input","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-05-30T07:11:21Z","receivedAt":"2013-05-30T07:11:21Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"--suppress-cc=self fails to filter sender address in many cases where it\nneeds to be sanitized in some way, for example quoted:\n\"A U. Thor\" <author@example.com>\nTo fix, make send-email sanitize both sender and the address it is\ncompared against.\n\nSigned-off-by: Michael S. Tsirkin <mst@redhat.com>\n---\n git-send-email.perl | 18 +++++++++++-------\n 1 file changed, 11 insertions(+), 7 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex a138615..92df393 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -760,6 +760,8 @@ if (!defined $sender) {\n \t$sender = $repoauthor || $repocommitter || '';\n }\n \n+$sender = sanitize_address($sender);\n+\n my $prompting = 0;\n if (!@initial_to && !defined $to_cmd) {\n \tmy $to = ask(\"Who should the emails be sent to (if any)? \",\n@@ -1113,10 +1115,9 @@ sub send_message {\n \tif ($cc ne '') {\n \t\t$ccline = \"\\nCc: $cc\";\n \t}\n-\tmy $sanitized_sender = sanitize_address($sender);\n \tmake_message_id() unless defined($message_id);\n \n-\tmy $header = \"From: $sanitized_sender\n+\tmy $header = \"From: $sender\n To: $to${ccline}\n Subject: $subject\n Date: $date\n@@ -1133,7 +1134,7 @@ X-Mailer: git-send-email $gitversion\n \t}\n \n \tmy @sendmail_parameters = ('-i', @recipients);\n-\tmy $raw_from = $sanitized_sender;\n+\tmy $raw_from = $sender;\n \tif (defined $envelope_sender && $envelope_sender ne \"auto\") {\n \t\t$raw_from = $envelope_sender;\n \t}\n@@ -1308,8 +1309,9 @@ foreach my $t (@files) {\n \t\t\t}\n \t\t\telsif (/^From:\\s+(.*)$/i) {\n \t\t\t\t($author, $author_encoding) = unquote_rfc2047($1);\n+\t\t\t\tmy $sauthor = sanitize_address($author);\n \t\t\t\tnext if $suppress_cc{'author'};\n-\t\t\t\tnext if $suppress_cc{'self'} and $author eq $sender;\n+\t\t\t\tnext if $suppress_cc{'self'} and $sauthor eq $sender;\n \t\t\t\tprintf(\"(mbox) Adding cc: %s from line '%s'\\n\",\n \t\t\t\t\t$1, $_) unless $quiet;\n \t\t\t\tpush @cc, $1;\n@@ -1323,7 +1325,9 @@ foreach my $t (@files) {\n \t\t\t}\n \t\t\telsif (/^Cc:\\s+(.*)$/i) {\n \t\t\t\tforeach my $addr (parse_address_line($1)) {\n-\t\t\t\t\tif (unquote_rfc2047($addr) eq $sender) {\n+\t\t\t\t\tmy $qaddr = unquote_rfc2047($addr);\n+\t\t\t\t\tmy $saddr = sanitize_address($qaddr);\n+\t\t\t\t\tif ($saddr eq $sender) {\n \t\t\t\t\t\tnext if ($suppress_cc{'self'});\n \t\t\t\t\t} else {\n \t\t\t\t\t\tnext if ($suppress_cc{'cc'});\n@@ -1370,7 +1374,8 @@ foreach my $t (@files) {\n \t\t\tchomp;\n \t\t\tmy ($what, $c) = ($1, $2);\n \t\t\tchomp $c;\n-\t\t\tif ($c eq $sender) {\n+\t\t\tmy $sc = sanitize_address($c);\n+\t\t\tif ($sc eq $sender) {\n \t\t\t\tnext if ($suppress_cc{'self'});\n \t\t\t} else {\n \t\t\t\tnext if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;\n@@ -1454,7 +1459,6 @@ foreach my $t (@files) {\n sub recipients_cmd {\n \tmy ($prefix, $what, $cmd, $file) = @_;\n \n-\tmy $sanitized_sender = sanitize_address($sender);\n \tmy @addresses = ();\n \topen my $fh, \"-|\", \"$cmd \\Q$file\\E\"\n \t    or die \"($prefix) Could not execute '$cmd'\";\n-- \nMST\n"},{"id":"218949","messageId":"1369897638-27299-6-git-send-email-mst@redhat.com","threadId":"33983","inReplyTo":"1369897638-27299-1-git-send-email-mst@redhat.com","subject":"[PATCH v2 5/6] t/send-email: add test with quoted sender","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-05-30T07:11:24Z","receivedAt":"2013-05-30T07:11:24Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"add test where sender address needs to be quoted.\nMake sure --suppress-cc=self works well in this case.\n\nSigned-off-by: Michael S. Tsirkin <mst@redhat.com>\n---\n t/t9001-send-email.sh | 20 ++++++++++++++++++++\n 1 file changed, 20 insertions(+)\n\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 452b362..42fb809 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -211,11 +211,31 @@ test_suppress_self_unquoted () {\n \tEOF\n }\n \n+test_suppress_self_quoted () {\n+\ttest_suppress_self \"$1\" \"$2\" \"quoted-$3\" <<-EOF\n+\t\ttest suppress-cc.self quoted-$3 with name $1 email $2\n+\n+\t\tquoted-$3\n+\n+\t\tcccmd--\"$1\" <$2>\n+\n+\t\tCc: $1 <$2>\n+\t\tCc: \"$1\" <$2>\n+\t\tSigned-off-by: $1 <$2>\n+\t\tSigned-off-by: \"$1\" <$2>\n+\tEOF\n+}\n+\n test_expect_success $PREREQ 'self name is suppressed' \"\n \ttest_suppress_self_unquoted 'A U Thor' 'author@redhat.com' \\\n \t\t'self_name_suppressed'\n \"\n \n+test_expect_success $PREREQ 'quoted self name is suppressed' \"\n+\ttest_suppress_self_quoted 'A U. Thor' 'author@redhat.com' \\\n+\t\t'self_name_suppressed'\n+\"\n+\n test_expect_success $PREREQ 'Show all headers' '\n \tgit send-email \\\n \t\t--dry-run \\\n-- \nMST\n"},{"id":"218950","messageId":"1369897638-27299-7-git-send-email-mst@redhat.com","threadId":"33983","inReplyTo":"1369897638-27299-1-git-send-email-mst@redhat.com","subject":"[PATCH v2 6/6] t/send-email: test suppress-cc=self with non-ascii","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-05-30T07:11:26Z","receivedAt":"2013-05-30T07:11:26Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"test suppress-cc=self when sender is non-acsii\n\nSigned-off-by: Michael S. Tsirkin <mst@redhat.com>\n---\n t/t9001-send-email.sh | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 42fb809..430e8de 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -236,6 +236,11 @@ test_expect_success $PREREQ 'quoted self name is suppressed' \"\n \t\t'self_name_suppressed'\n \"\n \n+test_expect_success $PREREQ 'non-ascii self name is suppressed' \"\n+\ttest_suppress_self_quoted 'Füñný Nâmé' 'odd_?=mail@example.com' \\\n+\t\t'non_ascii_self_suppressed'\n+\"\n+\n test_expect_success $PREREQ 'Show all headers' '\n \tgit send-email \\\n \t\t--dry-run \\\n-- \nMST\n"},{"id":"219234","messageId":"7v7gibjieh.fsf@alter.siamese.dyndns.org","threadId":"33983","inReplyTo":"1369897638-27299-3-git-send-email-mst@redhat.com","subject":"Re: [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-03T15:58:14Z","receivedAt":"2013-06-03T15:58:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Michael S. Tsirkin\" <mst@redhat.com> writes:\n\n> When cccmd is used, old-style suppress-from filter\n> is applied by the newer suppress-cc=self isn't.\n> Fix this up.\n>\n> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>\n> ---\n>  git-send-email.perl | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index bd13cc8..a138615 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -1462,7 +1462,7 @@ sub recipients_cmd {\n>  \t\t$address =~ s/^\\s*//g;\n>  \t\t$address =~ s/\\s*$//g;\n>  \t\t$address = sanitize_address($address);\n> -\t\tnext if ($address eq $sanitized_sender and $suppress_from);\n> +\t\tnext if ($address eq $sender and $suppress_cc{'self'});\n\nIf $suppress_from is defined, $suppress_cc{'self'} gets its value,\nso the latter half of this change is very understandable.\n\nThe original comparison uses $address that is \"sanitized\" (whose\ndefinition is roughly \"mangled/quoted with rfc2047 etc to fit on\nTo/Cc headers\") against $sanitized_sender, which means for a\n\n    $sender = 'Michael S. Tsirkin <mst@redhat.com>';\n\nwe used\n\n    $sanitized_sender = '\"Michael S. Tsirkin\" <mst@redhat.com>';\n\nfor comparison, but the new code does not quote the $recipient_name\npart inside dq for the single dot after the middle name.  Is this a\ndesirable change?\n\n>  \t\tpush @addresses, $address;\n>  \t\tprintf(\"($prefix) Adding %s: %s from: '%s'\\n\",\n>  \t\t       $what, $address, $cmd) unless $quiet;\n"},{"id":"219237","messageId":"20130603161556.GA16750@redhat.com","threadId":"33983","inReplyTo":"7v7gibjieh.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-06-03T16:15:56Z","receivedAt":"2013-06-03T16:15:56Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"On Mon, Jun 03, 2013 at 08:58:14AM -0700, Junio C Hamano wrote:\n> \"Michael S. Tsirkin\" <mst@redhat.com> writes:\n> \n> > When cccmd is used, old-style suppress-from filter\n> > is applied by the newer suppress-cc=self isn't.\n> > Fix this up.\n> >\n> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>\n> > ---\n> >  git-send-email.perl | 2 +-\n> >  1 file changed, 1 insertion(+), 1 deletion(-)\n> >\n> > diff --git a/git-send-email.perl b/git-send-email.perl\n> > index bd13cc8..a138615 100755\n> > --- a/git-send-email.perl\n> > +++ b/git-send-email.perl\n> > @@ -1462,7 +1462,7 @@ sub recipients_cmd {\n> >  \t\t$address =~ s/^\\s*//g;\n> >  \t\t$address =~ s/\\s*$//g;\n> >  \t\t$address = sanitize_address($address);\n> > -\t\tnext if ($address eq $sanitized_sender and $suppress_from);\n> > +\t\tnext if ($address eq $sender and $suppress_cc{'self'});\n> \n> If $suppress_from is defined, $suppress_cc{'self'} gets its value,\n> so the latter half of this change is very understandable.\n> \n> The original comparison uses $address that is \"sanitized\" (whose\n> definition is roughly \"mangled/quoted with rfc2047 etc to fit on\n> To/Cc headers\") against $sanitized_sender, which means for a\n> \n>     $sender = 'Michael S. Tsirkin <mst@redhat.com>';\n> \n> we used\n> \n>     $sanitized_sender = '\"Michael S. Tsirkin\" <mst@redhat.com>';\n> \n> for comparison, but the new code does not quote the $recipient_name\n> part inside dq for the single dot after the middle name.  Is this a\n> desirable change?\n\nWhat I tried to do here is split the changes to small\nchunks and I picked a chunk of a later patch in an earlier one\nby mistake.\n\nSo this is fixed up by patch 4/6\nin the series, which redefines sender to have\nthe sanitized value, everywhere.\n\nI guess I'll have to repost moving this former\nchunk to patch 4.\n\n\n> >  \t\tpush @addresses, $address;\n> >  \t\tprintf(\"($prefix) Adding %s: %s from: '%s'\\n\",\n> >  \t\t       $what, $address, $cmd) unless $quiet;\n"},{"id":"219238","messageId":"7v38szjhim.fsf@alter.siamese.dyndns.org","threadId":"33983","inReplyTo":"1369897638-27299-5-git-send-email-mst@redhat.com","subject":"Re: [PATCH v2 4/6] send-email: make --suppress-cc=self sanitize input","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-03T16:17:21Z","receivedAt":"2013-06-03T16:17:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Michael S. Tsirkin\" <mst@redhat.com> writes:\n\n> --suppress-cc=self fails to filter sender address in many cases where it\n> needs to be sanitized in some way, for example quoted:\n> \"A U. Thor\" <author@example.com>\n> To fix, make send-email sanitize both sender and the address it is\n> compared against.\n>\n> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>\n> ---\n\nOK, so you are getting rid of distinctions between sanitized_sender\nand sender, and $sender is now defined to be always \"sanitized\"\nform.\n\nThat change makes things consistent with respect to the question I\nhad on [2/6].\n\nI however wondered how this would affect those who have configured\n\"sendemail.from\" with an already \"sanitized\" address.  That is, you\nmay have used:\n\n\t[sendemail]\n        \tfrom = \"Michael S. Tsirkin\" <mst@redhat.com>\n\nwith the older and current versions of Git.  I _think_ the safetly\nof this change relies on that it is a no-op to run sanitize_address\non an already sanitized address (i.e. feeding the above example\nsendemail.from to sanitize_address gives back the same string),\nwhich holds true for all practical purposes, but it is a bit subtle.\n\n>  git-send-email.perl | 18 +++++++++++-------\n>  1 file changed, 11 insertions(+), 7 deletions(-)\n>\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index a138615..92df393 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -760,6 +760,8 @@ if (!defined $sender) {\n>  \t$sender = $repoauthor || $repocommitter || '';\n>  }\n>  \n> +$sender = sanitize_address($sender);\n> +\n>  my $prompting = 0;\n>  if (!@initial_to && !defined $to_cmd) {\n>  \tmy $to = ask(\"Who should the emails be sent to (if any)? \",\n> @@ -1113,10 +1115,9 @@ sub send_message {\n>  \tif ($cc ne '') {\n>  \t\t$ccline = \"\\nCc: $cc\";\n>  \t}\n> -\tmy $sanitized_sender = sanitize_address($sender);\n>  \tmake_message_id() unless defined($message_id);\n>  \n> -\tmy $header = \"From: $sanitized_sender\n> +\tmy $header = \"From: $sender\n>  To: $to${ccline}\n>  Subject: $subject\n>  Date: $date\n> @@ -1133,7 +1134,7 @@ X-Mailer: git-send-email $gitversion\n>  \t}\n>  \n>  \tmy @sendmail_parameters = ('-i', @recipients);\n> -\tmy $raw_from = $sanitized_sender;\n> +\tmy $raw_from = $sender;\n>  \tif (defined $envelope_sender && $envelope_sender ne \"auto\") {\n>  \t\t$raw_from = $envelope_sender;\n>  \t}\n> @@ -1308,8 +1309,9 @@ foreach my $t (@files) {\n>  \t\t\t}\n>  \t\t\telsif (/^From:\\s+(.*)$/i) {\n>  \t\t\t\t($author, $author_encoding) = unquote_rfc2047($1);\n> +\t\t\t\tmy $sauthor = sanitize_address($author);\n>  \t\t\t\tnext if $suppress_cc{'author'};\n> -\t\t\t\tnext if $suppress_cc{'self'} and $author eq $sender;\n> +\t\t\t\tnext if $suppress_cc{'self'} and $sauthor eq $sender;\n>  \t\t\t\tprintf(\"(mbox) Adding cc: %s from line '%s'\\n\",\n>  \t\t\t\t\t$1, $_) unless $quiet;\n>  \t\t\t\tpush @cc, $1;\n> @@ -1323,7 +1325,9 @@ foreach my $t (@files) {\n>  \t\t\t}\n>  \t\t\telsif (/^Cc:\\s+(.*)$/i) {\n>  \t\t\t\tforeach my $addr (parse_address_line($1)) {\n> -\t\t\t\t\tif (unquote_rfc2047($addr) eq $sender) {\n> +\t\t\t\t\tmy $qaddr = unquote_rfc2047($addr);\n> +\t\t\t\t\tmy $saddr = sanitize_address($qaddr);\n> +\t\t\t\t\tif ($saddr eq $sender) {\n>  \t\t\t\t\t\tnext if ($suppress_cc{'self'});\n>  \t\t\t\t\t} else {\n>  \t\t\t\t\t\tnext if ($suppress_cc{'cc'});\n> @@ -1370,7 +1374,8 @@ foreach my $t (@files) {\n>  \t\t\tchomp;\n>  \t\t\tmy ($what, $c) = ($1, $2);\n>  \t\t\tchomp $c;\n> -\t\t\tif ($c eq $sender) {\n> +\t\t\tmy $sc = sanitize_address($c);\n> +\t\t\tif ($sc eq $sender) {\n>  \t\t\t\tnext if ($suppress_cc{'self'});\n>  \t\t\t} else {\n>  \t\t\t\tnext if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;\n> @@ -1454,7 +1459,6 @@ foreach my $t (@files) {\n>  sub recipients_cmd {\n>  \tmy ($prefix, $what, $cmd, $file) = @_;\n>  \n> -\tmy $sanitized_sender = sanitize_address($sender);\n>  \tmy @addresses = ();\n>  \topen my $fh, \"-|\", \"$cmd \\Q$file\\E\"\n>  \t    or die \"($prefix) Could not execute '$cmd'\";\n"},{"id":"219239","messageId":"7vy5ari2vj.fsf@alter.siamese.dyndns.org","threadId":"33983","inReplyTo":"1369897638-27299-1-git-send-email-mst@redhat.com","subject":"Re: [PATCH v2 0/6] git send-email suppress-cc=self fixes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-03T16:18:56Z","receivedAt":"2013-06-03T16:18:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Michael S. Tsirkin\" <mst@redhat.com> writes:\n\n> This includes bugfixes related to handling of --suppress-cc=self\n> flag. Tests are also included.\n\nThanks, will queue.\n"},{"id":"219240","messageId":"7vk3mbi2u2.fsf@alter.siamese.dyndns.org","threadId":"33983","inReplyTo":"1369897638-27299-2-git-send-email-mst@redhat.com","subject":"Re: [PATCH v2 1/6] t/send-email.sh: add test for suppress-cc=self","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-03T16:19:49Z","receivedAt":"2013-06-03T16:19:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Michael S. Tsirkin\" <mst@redhat.com> writes:\n\n> This adds a basic test for --suppress-cc=self\n> option of git send-email.\n>\n> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>\n> ---\n>  t/t9001-send-email.sh | 43 +++++++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 43 insertions(+)\n>\n> diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\n> index ebd5c5d..e1a7f3e 100755\n> --- a/t/t9001-send-email.sh\n> +++ b/t/t9001-send-email.sh\n> @@ -171,6 +171,49 @@ Result: OK\n>  EOF\n>  \"\n>  \n> +test_suppress_self () {\n> +\ttest_commit $3 &&\n> +\ttest_when_finished \"git reset --hard HEAD^\" &&\n> +\n> +\twrite_script cccmd-sed <<-EOF &&\n> +\t\tsed -n -e s/^cccmd--//p \"\\$1\"\n> +\tEOF\n> +\n> +\tgit commit --amend --author=\"$1 <$2>\" -F - &&  \n\nAhh, this helper reads the log message from its standard input;\nnice.\n\n> +\tclean_fake_sendmail &&  \n> +\tgit format-patch --stdout -1 >\"suppress-self-$3.patch\" &&  \n> +\n> +\tgit send-email --from=\"$1 <$2>\" \\\n> +\t\t--to=nobody@example.com \\\n> +\t\t--cc-cmd=./cccmd-sed \\\n> +\t\t--suppress-cc=self \\\n> +\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n> +\t\tsuppress-self-$3.patch &&\n> +\n> +\tmv msgtxt1 msgtxt1-$3 &&\n> +\tsed -e '/^$/q' msgtxt1-$3 >\"msghdr1-$3\" &&\n> +\t>\"expected-no-cc-$3\" &&\n> +\n> +\t(grep '^Cc:' msghdr1-$3 >\"actual-no-cc-$3\";\n> +\t test_cmp expected-no-cc-$3 actual-no-cc-$3)\n> +}\n> +\n> +test_suppress_self_unquoted () {\n> +\ttest_suppress_self \"$1\" \"$2\" \"unquoted-$3\" <<-EOF\n> +\t\ttest suppress-cc.self unquoted-$3 with name $1 email $2\n> +\n> +\t\tunquoted-$3\n> +\n> +\t\tCc: $1 <$2>\n> +\t\tSigned-off-by: $1 <$2>\n> +\tEOF\n> +}\n> +\n> +test_expect_success $PREREQ 'self name is suppressed' \"\n> +\ttest_suppress_self_unquoted 'A U Thor' 'author@redhat.com' \\\n> +\t\t'self_name_suppressed'\n> +\"\n> +\n>  test_expect_success $PREREQ 'Show all headers' '\n>  \tgit send-email \\\n>  \t\t--dry-run \\\n"},{"id":"219241","messageId":"20130603163241.GB16841@redhat.com","threadId":"33983","inReplyTo":"7v38szjhim.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 4/6] send-email: make --suppress-cc=self sanitize input","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-06-03T16:32:41Z","receivedAt":"2013-06-03T16:32:41Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"On Mon, Jun 03, 2013 at 09:17:21AM -0700, Junio C Hamano wrote:\n> \"Michael S. Tsirkin\" <mst@redhat.com> writes:\n> \n> > --suppress-cc=self fails to filter sender address in many cases where it\n> > needs to be sanitized in some way, for example quoted:\n> > \"A U. Thor\" <author@example.com>\n> > To fix, make send-email sanitize both sender and the address it is\n> > compared against.\n> >\n> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>\n> > ---\n> \n> OK, so you are getting rid of distinctions between sanitized_sender\n> and sender, and $sender is now defined to be always \"sanitized\"\n> form.\n> \n> That change makes things consistent with respect to the question I\n> had on [2/6].\n> \n> I however wondered how this would affect those who have configured\n> \"sendemail.from\" with an already \"sanitized\" address.  That is, you\n> may have used:\n> \n> \t[sendemail]\n>         \tfrom = \"Michael S. Tsirkin\" <mst@redhat.com>\n> \n> with the older and current versions of Git.  I _think_ the safetly\n> of this change relies on that it is a no-op to run sanitize_address\n> on an already sanitized address (i.e. feeding the above example\n> sendemail.from to sanitize_address gives back the same string),\n> which holds true for all practical purposes, but it is a bit subtle.\n\nYes, I think so too. So - what do you suggest?\n\tAdd a test?\n\tAdd a comment?\nmore?\n\n> >  git-send-email.perl | 18 +++++++++++-------\n> >  1 file changed, 11 insertions(+), 7 deletions(-)\n> >\n> > diff --git a/git-send-email.perl b/git-send-email.perl\n> > index a138615..92df393 100755\n> > --- a/git-send-email.perl\n> > +++ b/git-send-email.perl\n> > @@ -760,6 +760,8 @@ if (!defined $sender) {\n> >  \t$sender = $repoauthor || $repocommitter || '';\n> >  }\n> >  \n> > +$sender = sanitize_address($sender);\n> > +\n> >  my $prompting = 0;\n> >  if (!@initial_to && !defined $to_cmd) {\n> >  \tmy $to = ask(\"Who should the emails be sent to (if any)? \",\n> > @@ -1113,10 +1115,9 @@ sub send_message {\n> >  \tif ($cc ne '') {\n> >  \t\t$ccline = \"\\nCc: $cc\";\n> >  \t}\n> > -\tmy $sanitized_sender = sanitize_address($sender);\n> >  \tmake_message_id() unless defined($message_id);\n> >  \n> > -\tmy $header = \"From: $sanitized_sender\n> > +\tmy $header = \"From: $sender\n> >  To: $to${ccline}\n> >  Subject: $subject\n> >  Date: $date\n> > @@ -1133,7 +1134,7 @@ X-Mailer: git-send-email $gitversion\n> >  \t}\n> >  \n> >  \tmy @sendmail_parameters = ('-i', @recipients);\n> > -\tmy $raw_from = $sanitized_sender;\n> > +\tmy $raw_from = $sender;\n> >  \tif (defined $envelope_sender && $envelope_sender ne \"auto\") {\n> >  \t\t$raw_from = $envelope_sender;\n> >  \t}\n> > @@ -1308,8 +1309,9 @@ foreach my $t (@files) {\n> >  \t\t\t}\n> >  \t\t\telsif (/^From:\\s+(.*)$/i) {\n> >  \t\t\t\t($author, $author_encoding) = unquote_rfc2047($1);\n> > +\t\t\t\tmy $sauthor = sanitize_address($author);\n> >  \t\t\t\tnext if $suppress_cc{'author'};\n> > -\t\t\t\tnext if $suppress_cc{'self'} and $author eq $sender;\n> > +\t\t\t\tnext if $suppress_cc{'self'} and $sauthor eq $sender;\n> >  \t\t\t\tprintf(\"(mbox) Adding cc: %s from line '%s'\\n\",\n> >  \t\t\t\t\t$1, $_) unless $quiet;\n> >  \t\t\t\tpush @cc, $1;\n> > @@ -1323,7 +1325,9 @@ foreach my $t (@files) {\n> >  \t\t\t}\n> >  \t\t\telsif (/^Cc:\\s+(.*)$/i) {\n> >  \t\t\t\tforeach my $addr (parse_address_line($1)) {\n> > -\t\t\t\t\tif (unquote_rfc2047($addr) eq $sender) {\n> > +\t\t\t\t\tmy $qaddr = unquote_rfc2047($addr);\n> > +\t\t\t\t\tmy $saddr = sanitize_address($qaddr);\n> > +\t\t\t\t\tif ($saddr eq $sender) {\n> >  \t\t\t\t\t\tnext if ($suppress_cc{'self'});\n> >  \t\t\t\t\t} else {\n> >  \t\t\t\t\t\tnext if ($suppress_cc{'cc'});\n> > @@ -1370,7 +1374,8 @@ foreach my $t (@files) {\n> >  \t\t\tchomp;\n> >  \t\t\tmy ($what, $c) = ($1, $2);\n> >  \t\t\tchomp $c;\n> > -\t\t\tif ($c eq $sender) {\n> > +\t\t\tmy $sc = sanitize_address($c);\n> > +\t\t\tif ($sc eq $sender) {\n> >  \t\t\t\tnext if ($suppress_cc{'self'});\n> >  \t\t\t} else {\n> >  \t\t\t\tnext if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;\n> > @@ -1454,7 +1459,6 @@ foreach my $t (@files) {\n> >  sub recipients_cmd {\n> >  \tmy ($prefix, $what, $cmd, $file) = @_;\n> >  \n> > -\tmy $sanitized_sender = sanitize_address($sender);\n> >  \tmy @addresses = ();\n> >  \topen my $fh, \"-|\", \"$cmd \\Q$file\\E\"\n> >  \t    or die \"($prefix) Could not execute '$cmd'\";\n"},{"id":"219243","messageId":"20130603163612.GC16841@redhat.com","threadId":"33983","inReplyTo":"7vy5ari2vj.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 0/6] git send-email suppress-cc=self fixes","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-06-03T16:36:12Z","receivedAt":"2013-06-03T16:36:12Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"On Mon, Jun 03, 2013 at 09:18:56AM -0700, Junio C Hamano wrote:\n> \"Michael S. Tsirkin\" <mst@redhat.com> writes:\n> \n> > This includes bugfixes related to handling of --suppress-cc=self\n> > flag. Tests are also included.\n> \n> Thanks, will queue.\n\nOK pls let me know if this means you intend to handle the rest of your\ncomments yourself or if I need to fix anything.\n"},{"id":"219262","messageId":"7vk3mbf4xw.fsf@alter.siamese.dyndns.org","threadId":"33983","inReplyTo":"20130603163241.GB16841@redhat.com","subject":"Re: [PATCH v2 4/6] send-email: make --suppress-cc=self sanitize input","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-03T18:02:35Z","receivedAt":"2013-06-03T18:02:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Michael S. Tsirkin\" <mst@redhat.com> writes:\n\n> Yes, I think so too. So - what do you suggest?\n> \tAdd a test?\n> \tAdd a comment?\n> more?\n\nNothing major comes to my mind at this moment.\n\nI guess it would be good to add a test or two to use \"A U. Thor\"\nexample with and without end-user added quotes, but that can be done\nas a follow-up patch on top of this series (i.e. [PATCH 7/6]).\n\nThanks.\n\n>> >  git-send-email.perl | 18 +++++++++++-------\n>> >  1 file changed, 11 insertions(+), 7 deletions(-)\n>> >\n>> > diff --git a/git-send-email.perl b/git-send-email.perl\n>> > index a138615..92df393 100755\n>> > --- a/git-send-email.perl\n>> > +++ b/git-send-email.perl\n>> > @@ -760,6 +760,8 @@ if (!defined $sender) {\n>> >  \t$sender = $repoauthor || $repocommitter || '';\n>> >  }\n>> >  \n>> > +$sender = sanitize_address($sender);\n>> > +\n>> >  my $prompting = 0;\n>> >  if (!@initial_to && !defined $to_cmd) {\n>> >  \tmy $to = ask(\"Who should the emails be sent to (if any)? \",\n>> > @@ -1113,10 +1115,9 @@ sub send_message {\n>> >  \tif ($cc ne '') {\n>> >  \t\t$ccline = \"\\nCc: $cc\";\n>> >  \t}\n>> > -\tmy $sanitized_sender = sanitize_address($sender);\n>> >  \tmake_message_id() unless defined($message_id);\n>> >  \n>> > -\tmy $header = \"From: $sanitized_sender\n>> > +\tmy $header = \"From: $sender\n>> >  To: $to${ccline}\n>> >  Subject: $subject\n>> >  Date: $date\n>> > @@ -1133,7 +1134,7 @@ X-Mailer: git-send-email $gitversion\n>> >  \t}\n>> >  \n>> >  \tmy @sendmail_parameters = ('-i', @recipients);\n>> > -\tmy $raw_from = $sanitized_sender;\n>> > +\tmy $raw_from = $sender;\n>> >  \tif (defined $envelope_sender && $envelope_sender ne \"auto\") {\n>> >  \t\t$raw_from = $envelope_sender;\n>> >  \t}\n>> > @@ -1308,8 +1309,9 @@ foreach my $t (@files) {\n>> >  \t\t\t}\n>> >  \t\t\telsif (/^From:\\s+(.*)$/i) {\n>> >  \t\t\t\t($author, $author_encoding) = unquote_rfc2047($1);\n>> > +\t\t\t\tmy $sauthor = sanitize_address($author);\n>> >  \t\t\t\tnext if $suppress_cc{'author'};\n>> > -\t\t\t\tnext if $suppress_cc{'self'} and $author eq $sender;\n>> > +\t\t\t\tnext if $suppress_cc{'self'} and $sauthor eq $sender;\n>> >  \t\t\t\tprintf(\"(mbox) Adding cc: %s from line '%s'\\n\",\n>> >  \t\t\t\t\t$1, $_) unless $quiet;\n>> >  \t\t\t\tpush @cc, $1;\n>> > @@ -1323,7 +1325,9 @@ foreach my $t (@files) {\n>> >  \t\t\t}\n>> >  \t\t\telsif (/^Cc:\\s+(.*)$/i) {\n>> >  \t\t\t\tforeach my $addr (parse_address_line($1)) {\n>> > -\t\t\t\t\tif (unquote_rfc2047($addr) eq $sender) {\n>> > +\t\t\t\t\tmy $qaddr = unquote_rfc2047($addr);\n>> > +\t\t\t\t\tmy $saddr = sanitize_address($qaddr);\n>> > +\t\t\t\t\tif ($saddr eq $sender) {\n>> >  \t\t\t\t\t\tnext if ($suppress_cc{'self'});\n>> >  \t\t\t\t\t} else {\n>> >  \t\t\t\t\t\tnext if ($suppress_cc{'cc'});\n>> > @@ -1370,7 +1374,8 @@ foreach my $t (@files) {\n>> >  \t\t\tchomp;\n>> >  \t\t\tmy ($what, $c) = ($1, $2);\n>> >  \t\t\tchomp $c;\n>> > -\t\t\tif ($c eq $sender) {\n>> > +\t\t\tmy $sc = sanitize_address($c);\n>> > +\t\t\tif ($sc eq $sender) {\n>> >  \t\t\t\tnext if ($suppress_cc{'self'});\n>> >  \t\t\t} else {\n>> >  \t\t\t\tnext if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i;\n>> > @@ -1454,7 +1459,6 @@ foreach my $t (@files) {\n>> >  sub recipients_cmd {\n>> >  \tmy ($prefix, $what, $cmd, $file) = @_;\n>> >  \n>> > -\tmy $sanitized_sender = sanitize_address($sender);\n>> >  \tmy @addresses = ();\n>> >  \topen my $fh, \"-|\", \"$cmd \\Q$file\\E\"\n>> >  \t    or die \"($prefix) Could not execute '$cmd'\";\n"},{"id":"219264","messageId":"7vd2s3f4uo.fsf@alter.siamese.dyndns.org","threadId":"33983","inReplyTo":"20130603161556.GA16750@redhat.com","subject":"Re: [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-03T18:04:31Z","receivedAt":"2013-06-03T18:04:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Michael S. Tsirkin\" <mst@redhat.com> writes:\n\n> What I tried to do here is split the changes to small chunks and I\n> picked a chunk of a later patch in an earlier one by mistake.\n>\n> So this is fixed up by patch 4/6 in the series, which redefines\n> sender to have the sanitized value, everywhere.\n>\n> I guess I'll have to repost moving this former chunk to patch 4.\n\nYeah, that may be a good idea.\n\nThanks.\n"},{"id":"219282","messageId":"20130603195833.GA18883@redhat.com","threadId":"33983","inReplyTo":"7vd2s3f4uo.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-06-03T19:58:34Z","receivedAt":"2013-06-03T19:58:34Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"On Mon, Jun 03, 2013 at 11:04:31AM -0700, Junio C Hamano wrote:\n> \"Michael S. Tsirkin\" <mst@redhat.com> writes:\n> \n> > What I tried to do here is split the changes to small chunks and I\n> > picked a chunk of a later patch in an earlier one by mistake.\n> >\n> > So this is fixed up by patch 4/6 in the series, which redefines\n> > sender to have the sanitized value, everywhere.\n> >\n> > I guess I'll have to repost moving this former chunk to patch 4.\n> \n> Yeah, that may be a good idea.\n> \n> Thanks.\n\nOr just smash 2+4 together ...\nConfused. You are doing this or want me ot?\n"},{"id":"219305","messageId":"7v7giadfm0.fsf@alter.siamese.dyndns.org","threadId":"33983","inReplyTo":"20130603195833.GA18883@redhat.com","subject":"Re: [PATCH v2 2/6] send-email: fix suppress-cc=self on cccmd","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-03T21:55:03Z","receivedAt":"2013-06-03T21:55:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Michael S. Tsirkin\" <mst@redhat.com> writes:\n\n> On Mon, Jun 03, 2013 at 11:04:31AM -0700, Junio C Hamano wrote:\n>> \"Michael S. Tsirkin\" <mst@redhat.com> writes:\n>> \n>> > What I tried to do here is split the changes to small chunks and I\n>> > picked a chunk of a later patch in an earlier one by mistake.\n>> >\n>> > So this is fixed up by patch 4/6 in the series, which redefines\n>> > sender to have the sanitized value, everywhere.\n>> >\n>> > I guess I'll have to repost moving this former chunk to patch 4.\n>> \n>> Yeah, that may be a good idea.\n>> \n>> Thanks.\n>\n> Or just smash 2+4 together ...\n> Confused. You are doing this or want me ot?\n\nSorry, I was expecting you would do so, after saying \"I'll have to\nrepost\" and I responded \"Yeah, good idea\".\n"}]}