{"thread":{"id":"34195","subject":"[PATCH 1/2] send-email: sanitize author when writing From line","startedAt":"2013-06-18T12:49:26Z","lastAt":"2013-06-18T13:55:24Z","messageCount":3,"participants":["Michael S. Tsirkin","SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"221212","messageId":"1371559723-28059-1-git-send-email-mst@redhat.com","threadId":"34195","inReplyTo":null,"subject":"[PATCH 1/2] send-email: sanitize author when writing From line","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-06-18T12:49:26Z","receivedAt":"2013-06-18T12:49:26Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"sender is now sanitized, but we didn't sanitize\nauthor when checking whether From: line is needed\nin the message body.\nAs a result git started writing duplicate From lines\nwhen author matched sender and has utf8 characters.\n\nReported-by: SZEDER Gábor <szeder@ira.uka.de>\nSigned-off-by: Michael S. Tsirkin <mst@redhat.com>\n---\n git-send-email.perl | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 671762b..ecbf56f 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1259,6 +1259,7 @@ foreach my $t (@files) {\n \topen my $fh, \"<\", $t or die \"can't open file $t\";\n \n \tmy $author = undef;\n+\tmy $sauthor = undef;\n \tmy $author_encoding;\n \tmy $has_content_type;\n \tmy $body_encoding;\n@@ -1297,7 +1298,7 @@ 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\t$sauthor = sanitize_address($author);\n \t\t\t\tnext if $suppress_cc{'author'};\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@@ -1393,7 +1394,7 @@ foreach my $t (@files) {\n \t\t$subject = quote_subject($subject, $auto_8bit_encoding);\n \t}\n \n-\tif (defined $author and $author ne $sender) {\n+\tif (defined $sauthor and $sauthor ne $sender) {\n \t\t$message = \"From: $author\\n\\n$message\";\n \t\tif (defined $author_encoding) {\n \t\t\tif ($has_content_type) {\n-- \nMST\n"},{"id":"221213","messageId":"1371559723-28059-2-git-send-email-mst@redhat.com","threadId":"34195","inReplyTo":"1371559723-28059-1-git-send-email-mst@redhat.com","subject":"[PATCH 2/2] send-email: add test for duplicate utf8 name","fromName":"Michael S. Tsirkin","fromEmail":"mst@redhat.com","sentAt":"2013-06-18T12:49:29Z","receivedAt":"2013-06-18T12:49:29Z","isPatch":true,"sender":{"key":"mst@kernel.org","avatar":null},"body":"Verify that author name is not duplicated if it matches\nsender, even if it is in utf8.\n\nSigned-off-by: Michael S. Tsirkin <mst@redhat.com>\n---\n t/t9001-send-email.sh | 13 +++++++++++++\n 1 file changed, 13 insertions(+)\n\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 9f46f22..cef884f 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -956,6 +956,19 @@ test_expect_success $PREREQ 'utf8 author is correctly passed on' '\n \tgrep \"^From: Füñný Nâmé <odd_?=mail@example.com>\" msgtxt1\n '\n \n+test_expect_success $PREREQ 'utf8 sender is not duplicated' '\n+\tclean_fake_sendmail &&\n+\ttest_commit weird_sender &&\n+\ttest_when_finished \"git reset --hard HEAD^\" &&\n+\tgit commit --amend --author \"Füñný Nâmé <odd_?=mail@example.com>\" &&\n+\tgit format-patch --stdout -1 >funny_name.patch &&\n+\tgit send-email --from=\"Füñný Nâmé <odd_?=mail@example.com>\" \\\n+\t  --to=nobody@example.com \\\n+\t  --smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t  funny_name.patch &&\n+\ttest `grep \"^From:\" msgtxt1|wc -l` -eq 1\n+'\n+\n test_expect_success $PREREQ 'sendemail.composeencoding works' '\n \tclean_fake_sendmail &&\n \tgit config sendemail.composeencoding iso-8859-1 &&\n-- \nMST\n"},{"id":"221220","messageId":"20130618135524.GC20052@goldbirke","threadId":"34195","inReplyTo":"1371559723-28059-2-git-send-email-mst@redhat.com","subject":"Re: [PATCH 2/2] send-email: add test for duplicate utf8 name","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2013-06-18T13:55:24Z","receivedAt":"2013-06-18T13:55:24Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Hi Michael,\n\n\nthanks for the quick turnaround.\n\nOn Tue, Jun 18, 2013 at 03:49:29PM +0300, Michael S. Tsirkin wrote:\n> Verify that author name is not duplicated if it matches\n> sender, even if it is in utf8.\n> \n> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>\n> ---\n>  t/t9001-send-email.sh | 13 +++++++++++++\n>  1 file changed, 13 insertions(+)\n> \n> diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\n> index 9f46f22..cef884f 100755\n> --- a/t/t9001-send-email.sh\n> +++ b/t/t9001-send-email.sh\n> @@ -956,6 +956,19 @@ test_expect_success $PREREQ 'utf8 author is correctly passed on' '\n>  \tgrep \"^From: Füñný Nâmé <odd_?=mail@example.com>\" msgtxt1\n>  '\n>  \n> +test_expect_success $PREREQ 'utf8 sender is not duplicated' '\n> +\tclean_fake_sendmail &&\n> +\ttest_commit weird_sender &&\n> +\ttest_when_finished \"git reset --hard HEAD^\" &&\n> +\tgit commit --amend --author \"Füñný Nâmé <odd_?=mail@example.com>\" &&\n> +\tgit format-patch --stdout -1 >funny_name.patch &&\n> +\tgit send-email --from=\"Füñný Nâmé <odd_?=mail@example.com>\" \\\n> +\t  --to=nobody@example.com \\\n> +\t  --smtp-server=\"$(pwd)/fake.sendmail\" \\\n> +\t  funny_name.patch &&\n> +\ttest `grep \"^From:\" msgtxt1|wc -l` -eq 1\n\nPerhaps you could use here\n\n  grep \"^From:\" msgtxt1 >from &&\n  test_line_count = 1 from\n\ninstead, to make it more debugging-friendly.\n\n> +'\n> +\n>  test_expect_success $PREREQ 'sendemail.composeencoding works' '\n>  \tclean_fake_sendmail &&\n>  \tgit config sendemail.composeencoding iso-8859-1 &&\n> -- \n> MST\n\nI couldn't apply this patch with git am/apply on top of today's master\nfor some reason, although the context lines seem to match exactly...\nin the end had to apply it manually.\n\nAnyway, 1/2 fixes my problem, so:\n\nTested-by: SZEDER Gábor <szeder@ira.uka.de>\n\n\nThanks,\nGábor\n"}]}