From a61c0ffa4474ad6dcec18a5454630371106710f4 Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Tue, 31 Mar 2009 12:22:14 -0400 Subject: [PATCH] send-email: ensure quoted addresses are rfc2047 encoded sanitize_address assumes that quoted addresses (e.g., "first last" Signed-off-by: Junio C Hamano --- git-send-email.perl | 3 ++- t/t9001-send-email.sh | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/git-send-email.perl b/git-send-email.perl index fc153f945..6bbdfec84 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -776,12 +776,13 @@ sub sanitize_address } # if recipient_name is already quoted, do nothing - if ($recipient_name =~ /^(".*"|=\?utf-8\?q\?.*\?=)$/) { + if ($recipient_name =~ /^("[[:ascii:]]*"|=\?utf-8\?q\?.*\?=)$/) { return $recipient; } # rfc2047 is needed if a non-ascii char is included if ($recipient_name =~ /[^[:ascii:]]/) { + $recipient_name =~ s/^"(.*)"$/$1/; $recipient_name = quote_rfc2047($recipient_name); } diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 84238f719..192b97b2d 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -505,6 +505,19 @@ test_expect_success 'confirm doesnt loop forever' ' test $ret = "0" ' +test_expect_success 'utf8 Cc is rfc2047 encoded' ' + clean_fake_sendmail && + rm -fr outdir && + git format-patch -1 -o outdir --cc="àéìöú " && + git send-email \ + --from="Example " \ + --to=nobody@example.com \ + --smtp-server="$(pwd)/fake.sendmail" \ + outdir/*.patch && + grep "^Cc:" msgtxt1 | + grep "=?utf-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= " +' + test_expect_success '--compose adds MIME for utf8 body' ' clean_fake_sendmail && (echo "#!$SHELL_PATH" && -- 2.26.2