@matheusbsbs / matheus-bagliano / commits / a61c0ffa44
Fork 0

send-email: ensure quoted addresses are rfc2047 encoded

sanitize_address assumes that quoted addresses (e.g., "first last" <first.last@example.com) do not need rfc2047 encoding, but this is not always the case. For example, various places in send-email extract addresses using parse_address_line. parse_address_line returns the addresses already quoted (e.g., "first last" <first.last@example.com), but not rfc2047 encoded. This patch makes sanitize_address stricter about what needs rfc2047 encoding and adds a test demonstrating where I noticed the problem. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jay Soffian committed Mar 31, 2009 at 12:22 UTC a61c0ffa4474ad6dcec18a5454630371106710f4
2 files changed +15 -1
git-send-email.perl
+2 -1
@@ -776,12 +776,13 @@ sub sanitize_address
776 }
777
778 # if recipient_name is already quoted, do nothing
779 - if ($recipient_name =~ /^(".*"|=\?utf-8\?q\?.*\?=)$/) {
779 + if ($recipient_name =~ /^("[[:ascii:]]*"|=\?utf-8\?q\?.*\?=)$/) {
780 return $recipient;
781 }
782
783 # rfc2047 is needed if a non-ascii char is included
784 if ($recipient_name =~ /[^[:ascii:]]/) {
785 + $recipient_name =~ s/^"(.*)"$/$1/;
786 $recipient_name = quote_rfc2047($recipient_name);
787 }
788
t/t9001-send-email.sh
+13
@@ -505,6 +505,19 @@ test_expect_success 'confirm doesnt loop forever' '
505 test $ret = "0"
506 '
507
508 +test_expect_success 'utf8 Cc is rfc2047 encoded' '
509 + clean_fake_sendmail &&
510 + rm -fr outdir &&
511 + git format-patch -1 -o outdir --cc="àéìöú <utf8@example.com>" &&
512 + git send-email \
513 + --from="Example <nobody@example.com>" \
514 + --to=nobody@example.com \
515 + --smtp-server="$(pwd)/fake.sendmail" \
516 + outdir/*.patch &&
517 + grep "^Cc:" msgtxt1 |
518 + grep "=?utf-8?q?=C3=A0=C3=A9=C3=AC=C3=B6=C3=BA?= <utf8@example.com>"
519 +'
520 +
521 test_expect_success '--compose adds MIME for utf8 body' '
522 clean_fake_sendmail &&
523 (echo "#!$SHELL_PATH" &&