mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
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: Роман Донченко <dpb@corrigendum.ru> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
11f70a7e29
commit
ab47e2a583
@@ -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) : $_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user