{"thread":{"id":"18726","subject":"[PATCH] send-email: ensure quoted addresses are rfc2047 encoded","startedAt":"2009-04-05T03:22:06Z","lastAt":"2009-04-05T03:23:05Z","messageCount":2,"participants":["Jay Soffian"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"110372","messageId":"1238901726-47026-1-git-send-email-jaysoffian@gmail.com","threadId":"18726","inReplyTo":null,"subject":"[PATCH] send-email: ensure quoted addresses are rfc2047 encoded","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-04-05T03:22:06Z","receivedAt":"2009-04-05T03:22:06Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"sanitize_address assumes that quoted addresses (e.g., \"first last\"\n<first.last@example.com) do not need rfc2047 encoding, but this is\nnot always the case.\n\nFor example, various places in send-email extract addresses using\nparse_address_line. parse_address_line returns the addresses already\nquoted (e.g., \"first last\" <first.last@example.com), but not rfc2047\nencoded.\n\nThis patch makes sanitize_address stricter about what needs rfc2047\nencoding and adds a test demonstrating where I noticed the problem.\n---\n git-send-email.perl   |    3 ++-\n t/t9001-send-email.sh |   13 +++++++++++++\n 2 files changed, 15 insertions(+), 1 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex fc153f9..6bbdfec 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -776,12 +776,13 @@ sub sanitize_address\n \t}\n \n \t# if recipient_name is already quoted, do nothing\n-\tif ($recipient_name =~ /^(\".*\"|=\\?utf-8\\?q\\?.*\\?=)$/) {\n+\tif ($recipient_name =~ /^(\"[[:ascii:]]*\"|=\\?utf-8\\?q\\?.*\\?=)$/) {\n \t\treturn $recipient;\n \t}\n \n \t# rfc2047 is needed if a non-ascii char is included\n \tif ($recipient_name =~ /[^[:ascii:]]/) {\n+\t\t$recipient_name =~ s/^\"(.*)\"$/$1/;\n \t\t$recipient_name = quote_rfc2047($recipient_name);\n \t}\n \ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 84238f7..192b97b 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -505,6 +505,19 @@ test_expect_success 'confirm doesnt loop forever' '\n \ttest $ret = \"0\"\n '\n \n+test_expect_success 'utf8 Cc is rfc2047 encoded' '\n+\tclean_fake_sendmail &&\n+\trm -fr outdir &&\n+\tgit format-patch -1 -o outdir --cc=\"Ã Ã©Ã¬Ã¶Ãº <utf8@example.com>\" &&\n+\tgit send-email \\\n+\t--from=\"Example <nobody@example.com>\" \\\n+\t--to=nobody@example.com \\\n+\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\toutdir/*.patch &&\n+\tgrep \"^Cc:\" msgtxt1 |\n+\tgrep \"=?utf-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>\"\n+'\n+\n test_expect_success '--compose adds MIME for utf8 body' '\n \tclean_fake_sendmail &&\n \t(echo \"#!$SHELL_PATH\" &&\n-- \n1.6.2.1.427.g15408\n"},{"id":"110373","messageId":"76718490904042023i3090dd79t8a8d11b21c0f7e13@mail.gmail.com","threadId":"18726","inReplyTo":"1238901726-47026-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH] send-email: ensure quoted addresses are rfc2047 encoded","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-04-05T03:23:05Z","receivedAt":"2009-04-05T03:23:05Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Sat, Apr 4, 2009 at 11:22 PM, Jay Soffian <jaysoffian@gmail.com> wrote:\n> sanitize_address assumes that quoted addresses (e.g., \"first last\"\n> <first.last@example.com) do not need rfc2047 encoding, but this is\n> not always the case.\n\nOOOOOOOPPPS. Ignore.\n\nj.\n"}]}