Skip to content

Commit

Permalink
Encode: sync with CPAN version 3.18
Browse files Browse the repository at this point in the history
  • Loading branch information
dankogai authored and jkeenan committed Jun 25, 2022
1 parent 7b92fe4 commit d26b5e1
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Porting/Maintainers.pl
Expand Up @@ -387,7 +387,7 @@ package Maintainers;
},

'Encode' => {
'DISTRIBUTION' => 'DANKOGAI/Encode-3.17.tar.gz',
'DISTRIBUTION' => 'DANKOGAI/Encode-3.18.tar.gz',
'FILES' => q[cpan/Encode],
'EXCLUDED' => [
qw( t/whatwg-aliases.json
Expand Down
4 changes: 2 additions & 2 deletions cpan/Encode/Encode.pm
@@ -1,13 +1,13 @@
#
# $Id: Encode.pm,v 3.17 2022/04/07 03:05:51 dankogai Exp $
# $Id: Encode.pm,v 3.18 2022/06/25 02:04:06 dankogai Exp $
#
package Encode;
use strict;
use warnings;
use constant DEBUG => !!$ENV{PERL_ENCODE_DEBUG};
our $VERSION;
BEGIN {
$VERSION = sprintf "%d.%02d", q$Revision: 3.17 $ =~ /(\d+)/g;
$VERSION = sprintf "%d.%02d", q$Revision: 3.18 $ =~ /(\d+)/g;
require XSLoader;
XSLoader::load( __PACKAGE__, $VERSION );
}
Expand Down
4 changes: 3 additions & 1 deletion cpan/Encode/Makefile.PL
@@ -1,5 +1,5 @@
#
# $Id: Makefile.PL,v 2.24 2021/10/13 08:29:13 dankogai Exp $
# $Id: Makefile.PL,v 2.25 2022/06/25 01:58:57 dankogai Exp $
#
use 5.007003;
use strict;
Expand All @@ -17,6 +17,8 @@ $ENV{PERL_CORE} ||= $ARGV{PERL_CORE} if $ARGV{PERL_CORE};
my $ccflags = $Config{ccflags};
if (!$ENV{PERL_CORE}) {
if (my $gccver = $Config{gccversion}) {
# no more 'Argument "Apple" isn't numeric in addition (+)'
no warnings 'numeric';
$gccver =~ s/\.//g; $gccver =~ s/ .*//;
$gccver .= "0" while length $gccver < 3;
$gccver = 0+$gccver;
Expand Down
8 changes: 6 additions & 2 deletions cpan/Encode/lib/Encode/MIME/Header.pm
Expand Up @@ -2,7 +2,7 @@ package Encode::MIME::Header;
use strict;
use warnings;

our $VERSION = do { my @r = ( q$Revision: 2.28 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r };
our $VERSION = do { my @r = ( q$Revision: 2.29 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r };

use Carp ();
use Encode ();
Expand Down Expand Up @@ -55,7 +55,7 @@ my $re_capture_encoded_word_split = qr/=\?($re_charset)((?:\*$re_language)?)\?($
# in strict mode check also for valid base64 characters and also for valid quoted printable codes
my $re_encoding_strict_b = qr/[Bb]/;
my $re_encoding_strict_q = qr/[Qq]/;
my $re_encoded_text_strict_b = qr/[0-9A-Za-z\+\/]*={0,2}/;
my $re_encoded_text_strict_b = qr/(?:[0-9A-Za-z\+\/]{4})*(?:[0-9A-Za-z\+\/]{2}==|[0-9A-Za-z\+\/]{3}=|)/;
my $re_encoded_text_strict_q = qr/(?:[\x21-\x3C\x3E\x40-\x7E]|=[0-9A-Fa-f]{2})*/; # NOTE: first part are printable US-ASCII except ?, =, SPACE and TAB
my $re_encoded_word_strict = qr/=\?$re_charset(?:\*$re_language)?\?(?:$re_encoding_strict_b\?$re_encoded_text_strict_b|$re_encoding_strict_q\?$re_encoded_text_strict_q)\?=/;
my $re_capture_encoded_word_strict = qr/=\?($re_charset)((?:\*$re_language)?)\?($re_encoding_strict_b\?$re_encoded_text_strict_b|$re_encoding_strict_q\?$re_encoded_text_strict_q)\?=/;
Expand Down Expand Up @@ -94,6 +94,10 @@ sub decode($$;$) {
$stop = 1 unless length($line) or length($sep);
# in non strict mode append missing '=' padding characters for b words
# fixes below concatenation of consecutive encoded mime words
1 while not $STRICT_DECODE and $line =~ s/(=\?$re_charset(?:\*$re_language)?\?[Bb]\?)((?:[^\?]{4})*[^\?]{1,3})(\?=)/$1.$2.('='x(4-length($2)%4)).$3/se;
# NOTE: this code partially could break $chk support
# in non strict mode concat consecutive encoded mime words with same charset, language and encoding
# fixes breaking inside multi-byte characters
Expand Down
6 changes: 6 additions & 0 deletions cpan/Encode/t/Unicode_trailing_nul.t
@@ -1,3 +1,9 @@
BEGIN {
if ( $] < 5.009 ) {
print "1..0 # Skip: Perl <= 5.9 or later required\n";
exit 0;
}
}
use strict;
use Test::More;

Expand Down
2 changes: 1 addition & 1 deletion cpan/Encode/t/enc_data.t
@@ -1,4 +1,4 @@
# $Id: enc_data.t,v 2.6 2022/04/07 03:06:40 dankogai Exp dankogai $
# $Id: enc_data.t,v 2.6 2022/04/07 03:06:40 dankogai Exp $

BEGIN {
require Config; import Config;
Expand Down
2 changes: 1 addition & 1 deletion cpan/Encode/t/enc_module.t
@@ -1,4 +1,4 @@
# $Id: enc_module.t,v 2.6 2022/04/07 03:06:40 dankogai Exp dankogai $
# $Id: enc_module.t,v 2.6 2022/04/07 03:06:40 dankogai Exp $
# This file is in euc-jp
BEGIN {
require Config; import Config;
Expand Down
2 changes: 1 addition & 1 deletion cpan/Encode/t/jperl.t
@@ -1,5 +1,5 @@
#
# $Id: jperl.t,v 2.6 2022/04/07 03:06:40 dankogai Exp dankogai $
# $Id: jperl.t,v 2.6 2022/04/07 03:06:40 dankogai Exp $
#
# This script is written in euc-jp

Expand Down
14 changes: 12 additions & 2 deletions cpan/Encode/t/mime-header.t
@@ -1,5 +1,5 @@
#
# $Id: mime-header.t,v 2.15 2017/07/18 07:15:29 dankogai Exp $
# $Id: mime-header.t,v 2.16 2022/06/25 01:58:57 dankogai Exp $
# This script is written in utf8
#
BEGIN {
Expand All @@ -24,7 +24,7 @@ use strict;
use utf8;
use charnames ":full";

use Test::More tests => 266;
use Test::More tests => 274;

BEGIN {
use_ok("Encode::MIME::Header");
Expand Down Expand Up @@ -138,6 +138,11 @@ my @decode_default_tests = (
"=?utf-8-strict?Q?=C3=A1=f9=80=80=80=80?=" => "á�",
# allow non-ASCII characters in q word
"=?UTF-8?Q?\x{C3}\x{A1}?=" => "á",
# allow missing padding characters '=' in b word
"=?UTF-8?B?JQ?=" => "%",
"=?UTF-8?B?JQ?= =?UTF-8?B?JQ?=" => "%%",
"=?UTF-8?B?YWI?=" => "ab",
"=?UTF-8?B?YWI?= =?UTF-8?B?YWI?=" => "abab",
);

my @decode_strict_tests = (
Expand All @@ -159,6 +164,11 @@ my @decode_strict_tests = (
"=?utf-8-strict?Q?=C3=A1?=" => "=?utf-8-strict?Q?=C3=A1?=",
# do not allow non-ASCII characters in q word
"=?UTF-8?Q?\x{C3}\x{A1}?=" => "=?UTF-8?Q?\x{C3}\x{A1}?=",
# do not allow missing padding characters '=' in b word
"=?UTF-8?B?JQ?=" => "=?UTF-8?B?JQ?=",
"=?UTF-8?B?JQ?= =?UTF-8?B?JQ?=" => "=?UTF-8?B?JQ?= =?UTF-8?B?JQ?=",
"=?UTF-8?B?YWI?=" => "=?UTF-8?B?YWI?=",
"=?UTF-8?B?YWI?= =?UTF-8?B?YWI?=" => "=?UTF-8?B?YWI?= =?UTF-8?B?YWI?=",
);

my @encode_tests = (
Expand Down
4 changes: 4 additions & 0 deletions cpan/Encode/t/truncated_utf8.t
Expand Up @@ -12,6 +12,10 @@ BEGIN {
print "1..0 # Skip: EBCDIC\n";
exit 0;
}
if ( $] < 5.009 ) {
print "1..0 # Skip: Perl <= 5.9 or later required\n";
exit 0;
}
$| = 1;
}

Expand Down
6 changes: 6 additions & 0 deletions cpan/Encode/t/utf32warnings.t
@@ -1,3 +1,9 @@
BEGIN {
if ( $] < 5.009 ) {
print "1..0 # Skip: Perl <= 5.9 or later required\n";
exit 0;
}
}
use strict;
use warnings;

Expand Down
8 changes: 7 additions & 1 deletion cpan/Encode/t/xml.t
@@ -1,3 +1,9 @@
BEGIN {
if ( $] < 5.009 ) {
print "1..0 # Skip: Perl <= 5.9 or later required\n";
exit 0;
}
}
use strict;
use warnings;

Expand All @@ -8,7 +14,7 @@ my $content = String->new("--\x{30c6}--");
my $text = Encode::encode('latin1', $content, Encode::FB_XMLCREF);
is $text, "--&#x30c6;--";

done_testing;
done_testing();

package String;
use overload
Expand Down

0 comments on commit d26b5e1

Please sign in to comment.