From ab47e2a583917ecef5da269cc640f8359c8467ac Mon Sep 17 00:00:00 2001 From: Роман Донченко Date: Sun, 14 Dec 2014 18:59:47 +0300 Subject: send-email: handle adjacent RFC 2047-encoded words properly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- git-send-email.perl | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'git-send-email.perl') 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) : $_; } -- cgit v1.3-5-g45d5