From: Роман Донченко Date: Sun, 14 Dec 2014 15:59:47 +0000 (+0300) Subject: send-email: handle adjacent RFC 2047-encoded words properly X-Git-Tag: v2.3.0-rc0~20^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ab47e2a583917ecef5da269cc640f8359c8467ac;p=thirdparty%2Fgit.git send-email: handle adjacent RFC 2047-encoded words properly The RFC says that they are to be concatenated after decoding (i.e. the intervening whitespace is ignored). Signed-off-by: Роман Донченко Acked-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/git-send-email.perl b/git-send-email.perl index 106c2b065d..cd327d7043 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -912,17 +912,23 @@ $time = time - scalar $#files; sub unquote_rfc2047 { local ($_) = @_; my $charset; - s{$re_encoded_word}{ - $charset = $1; - my $encoding = $2; - my $text = $3; - if ($encoding eq 'q' || $encoding eq 'Q') { - $text =~ s/_/ /g; - $text =~ s/=([0-9A-F]{2})/chr(hex($1))/egi; - $text; - } else { - $&; # other encodings not supported yet + my $sep = qr/[ \t]+/; + s{$re_encoded_word(?:$sep$re_encoded_word)*}{ + my @words = split $sep, $&; + foreach (@words) { + m/$re_encoded_word/; + $charset = $1; + my $encoding = $2; + my $text = $3; + if ($encoding eq 'q' || $encoding eq 'Q') { + $_ = $text; + s/_/ /g; + s/=([0-9A-F]{2})/chr(hex($1))/egi; + } else { + # other encodings not supported yet + } } + join '', @words; }eg; return wantarray ? ($_, $charset) : $_; } diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 1ecdacb6fd..f933bc7ec7 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -240,6 +240,13 @@ test_expect_success $PREREQ 'non-ascii self name is suppressed' " 'non_ascii_self_suppressed' " +# This name is long enough to force format-patch to split it into multiple +# encoded-words, assuming it uses UTF-8 with the "Q" encoding. +test_expect_success $PREREQ 'long non-ascii self name is suppressed' " + test_suppress_self_quoted 'Ƒüñníęř €. Nâṁé' 'odd_?=mail@example.com' \ + 'long_non_ascii_self_suppressed' +" + test_expect_success $PREREQ 'sanitized self name is suppressed' " test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \ 'self_name_sanitized_suppressed'