Merge branch 'rd/send-email-2047-fix'
"git send-email" did not handle RFC 2047 encoded headers quite right. * rd/send-email-2047-fix: send-email: handle adjacent RFC 2047-encoded words properly send-email: align RFC 2047 decoding more closely with the spec
This commit is contained in:
commit
948e81408d
@ -146,6 +146,11 @@ my $have_mail_address = eval { require Mail::Address; 1 };
|
|||||||
my $smtp;
|
my $smtp;
|
||||||
my $auth;
|
my $auth;
|
||||||
|
|
||||||
|
# Regexes for RFC 2047 productions.
|
||||||
|
my $re_token = qr/[^][()<>@,;:\\"\/?.= \000-\037\177-\377]+/;
|
||||||
|
my $re_encoded_text = qr/[^? \000-\037\177-\377]+/;
|
||||||
|
my $re_encoded_word = qr/=\?($re_token)\?($re_token)\?($re_encoded_text)\?=/;
|
||||||
|
|
||||||
# Variables we fill in automatically, or via prompting:
|
# Variables we fill in automatically, or via prompting:
|
||||||
my (@to,$no_to,@initial_to,@cc,$no_cc,@initial_cc,@bcclist,$no_bcc,@xh,
|
my (@to,$no_to,@initial_to,@cc,$no_cc,@initial_cc,@bcclist,$no_bcc,@xh,
|
||||||
$initial_reply_to,$initial_subject,@files,
|
$initial_reply_to,$initial_subject,@files,
|
||||||
@ -917,15 +922,26 @@ $time = time - scalar $#files;
|
|||||||
|
|
||||||
sub unquote_rfc2047 {
|
sub unquote_rfc2047 {
|
||||||
local ($_) = @_;
|
local ($_) = @_;
|
||||||
my $encoding;
|
my $charset;
|
||||||
s{=\?([^?]+)\?q\?(.*?)\?=}{
|
my $sep = qr/[ \t]+/;
|
||||||
$encoding = $1;
|
s{$re_encoded_word(?:$sep$re_encoded_word)*}{
|
||||||
my $e = $2;
|
my @words = split $sep, $&;
|
||||||
$e =~ s/_/ /g;
|
foreach (@words) {
|
||||||
$e =~ s/=([0-9A-F]{2})/chr(hex($1))/eg;
|
m/$re_encoded_word/;
|
||||||
$e;
|
$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;
|
}eg;
|
||||||
return wantarray ? ($_, $encoding) : $_;
|
return wantarray ? ($_, $charset) : $_;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub quote_rfc2047 {
|
sub quote_rfc2047 {
|
||||||
@ -938,10 +954,8 @@ sub quote_rfc2047 {
|
|||||||
|
|
||||||
sub is_rfc2047_quoted {
|
sub is_rfc2047_quoted {
|
||||||
my $s = shift;
|
my $s = shift;
|
||||||
my $token = qr/[^][()<>@,;:"\/?.= \000-\037\177-\377]+/;
|
|
||||||
my $encoded_text = qr/[!->@-~]+/;
|
|
||||||
length($s) <= 75 &&
|
length($s) <= 75 &&
|
||||||
$s =~ m/^(?:"[[:ascii:]]*"|=\?$token\?$token\?$encoded_text\?=)$/o;
|
$s =~ m/^(?:"[[:ascii:]]*"|$re_encoded_word)$/o;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub subject_needs_rfc2047_quoting {
|
sub subject_needs_rfc2047_quoting {
|
||||||
|
@ -242,6 +242,13 @@ test_expect_success $PREREQ 'non-ascii self name is suppressed' "
|
|||||||
'non_ascii_self_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_expect_success $PREREQ 'sanitized self name is suppressed' "
|
||||||
test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \
|
test_suppress_self_unquoted '\"A U. Thor\"' 'author@example.com' \
|
||||||
'self_name_sanitized_suppressed'
|
'self_name_sanitized_suppressed'
|
||||||
|
Loading…
Reference in New Issue
Block a user