summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2022-07-19 16:24:00 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2022-07-19 16:24:00 +0900
commitc7c962a282ca30e60db54b2a9786cd3478707d9d (patch)
tree1460f0008ae23f12bc39f08279fc3019adeb753e
parent80e2994434f3c840ce12546351ab9fd20cdd3aaa (diff)
downloadperl-json-c7c962a282ca30e60db54b2a9786cd3478707d9d.tar.gz
perl-json-c7c962a282ca30e60db54b2a9786cd3478707d9d.tar.bz2
perl-json-c7c962a282ca30e60db54b2a9786cd3478707d9d.zip
Imported Upstream version 4.04upstream/4.04
-rw-r--r--.travis.yml32
-rw-r--r--Changes3
-rw-r--r--MANIFEST3
-rw-r--r--META.json4
-rw-r--r--META.yml2
-rw-r--r--lib/JSON.pm4
-rw-r--r--lib/JSON/backportPP.pm11
-rw-r--r--lib/JSON/backportPP/Boolean.pm2
-rw-r--r--t/107_allow_singlequote.t2
-rw-r--r--t/119_incr_parse_utf8.t77
-rw-r--r--t/rt_122270_is_bool_for_obsolete_xs_boolean.t33
11 files changed, 128 insertions, 45 deletions
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 3611047..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-dist: trusty
-language: perl
-perl:
- - "5.8"
- - "5.24"
-matrix:
- include:
- - perl: 5.8
- env: JSON_XS_VERSION=4.00
- - perl: 5.8
- env: JSON_XS_VERSION=3.02
- - perl: 5.8
- env: JSON_XS_VERSION=2.34
- - perl: 5.8
- env: JSON_PP_VERSION=2.97001
- - perl: 5.8
- env: JSON_PP_VERSION=2.27400
- - perl: 5.8
- env: JSON_PP_VERSION=2.27101
- - perl: 5.8
- env: CPANEL_JSON_XS_VERSION=3.0218
- - perl: 5.8
- env: CPANEL_JSON_XS_VERSION=4.08
-before_install:
- - test $JSON_PP_VERSION && cpanm -n JSON::XS@$JSON_XS_VERSION || true
- - test $JSON_XS_VERSION && cpanm -n JSON::XS@$JSON_XS_VERSION || true
- - test $CPANEL_JSON_XS_VERSION && cpanm -n Cpanel::JSON::XS@$CPANEL_JSON_XS_VERSION || true
-script:
- - if test ! $JSON_PP_VERSION && test ! $JSON_XS_VERSION && test ! $CPANEL_JSON_XS_VERSION; then perl Makefile.PL && PERL_JSON_BACKEND=JSON::backportPP make test; else true; fi
- - if test $JSON_PP_VERSION; then perl Makefile.PL && PERL_JSON_BACKEND=JSON::PP make test; else true; fi
- - if test $JSON_XS_VERSION; then perl Makefile.PL && PERL_JSON_BACKEND=JSON::XS make test; else true; fi
- - if test $CPANEL_JSON_XS_VERSION; then perl Makefile.PL && PERL_JSON_BACKEND=Cpanel::JSON::XS make test; else true; fi
diff --git a/Changes b/Changes
index cb65f77..4eb22e9 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
Revision history for Perl extension JSON.
+4.04 2021-12-17
+ - updated backportPP with JSON::PP 4.07
+
4.03 2021-01-24
- corrected one typo in POD (James E Keenan)
- updated backportPP with JSON::PP 4.06
diff --git a/MANIFEST b/MANIFEST
index 00b351c..79f6318 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,4 +1,3 @@
-.travis.yml
Changes
eg/bench_decode.pl
eg/bench_encode.pl
@@ -38,6 +37,7 @@ t/115_tie_ixhash.t
t/116_incr_parse_fixed.t
t/117_numbers.t
t/118_boolean_values.t
+t/119_incr_parse_utf8.t
t/11_pc_expo.t
t/12_blessed.t
t/13_limit.t
@@ -62,6 +62,7 @@ t/e90_misc.t
t/gh_28_json_test_suite.t
t/gh_29_trailing_false_value.t
t/rt_116998_wrong_character_offset.t
+t/rt_122270_is_bool_for_obsolete_xs_boolean.t
t/rt_90071_incr_parse.t
t/x00_load.t
t/x02_error.t
diff --git a/META.json b/META.json
index c6913a8..9233cc3 100644
--- a/META.json
+++ b/META.json
@@ -48,6 +48,6 @@
"url" : "https://github.com/makamaka/JSON"
}
},
- "version" : "4.03",
- "x_serialization_backend" : "JSON version 4.03"
+ "version" : "4.04",
+ "x_serialization_backend" : "JSON version 4.04"
}
diff --git a/META.yml b/META.yml
index b4bc9ba..2976089 100644
--- a/META.yml
+++ b/META.yml
@@ -24,5 +24,5 @@ requires:
resources:
bugtracker: https://github.com/makamaka/JSON/issues
repository: https://github.com/makamaka/JSON
-version: '4.03'
+version: '4.04'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff --git a/lib/JSON.pm b/lib/JSON.pm
index 3e644cc..a90c346 100644
--- a/lib/JSON.pm
+++ b/lib/JSON.pm
@@ -9,7 +9,7 @@ BEGIN { @JSON::ISA = 'Exporter' }
@JSON::EXPORT = qw(from_json to_json jsonToObj objToJson encode_json decode_json);
BEGIN {
- $JSON::VERSION = '4.03';
+ $JSON::VERSION = '4.04';
$JSON::DEBUG = 0 unless (defined $JSON::DEBUG);
$JSON::DEBUG = $ENV{ PERL_JSON_DEBUG } if exists $ENV{ PERL_JSON_DEBUG };
}
@@ -1595,7 +1595,7 @@ argument being the object to serialise, and the second argument being the
constant string C<JSON> to distinguish it from other serialisers.
The C<FREEZE> method can return any number of values (i.e. zero or
-more). These values and the paclkage/classname of the object will then be
+more). These values and the package/classname of the object will then be
encoded as a tagged JSON value in the following format:
("classname")[FREEZE return values...]
diff --git a/lib/JSON/backportPP.pm b/lib/JSON/backportPP.pm
index 3c9c392..dfb134e 100644
--- a/lib/JSON/backportPP.pm
+++ b/lib/JSON/backportPP.pm
@@ -15,7 +15,7 @@ use JSON::backportPP::Boolean;
use Carp ();
#use Devel::Peek;
-$JSON::backportPP::VERSION = '4.06';
+$JSON::backportPP::VERSION = '4.07';
@JSON::PP::EXPORT = qw(encode_json decode_json from_json to_json);
@@ -1566,6 +1566,11 @@ sub incr_parse {
}
}
+ unless ( $coder->get_utf8 ) {
+ utf8::upgrade( $self->{incr_text} );
+ utf8::decode( $self->{incr_text} );
+ }
+
my ($obj, $offset) = $coder->PP_decode_json( $self->{incr_text}, 0x00000001 );
push @ret, $obj;
use bytes;
@@ -1773,10 +1778,6 @@ JSON::PP - JSON::XS compatible pure-Perl module.
use JSON;
-=head1 VERSION
-
- 4.05
-
=head1 DESCRIPTION
JSON::PP is a pure perl JSON decoder/encoder, and (almost) compatible to much
diff --git a/lib/JSON/backportPP/Boolean.pm b/lib/JSON/backportPP/Boolean.pm
index efccd61..d6a2d58 100644
--- a/lib/JSON/backportPP/Boolean.pm
+++ b/lib/JSON/backportPP/Boolean.pm
@@ -11,7 +11,7 @@ overload::import('overload',
fallback => 1,
);
-$JSON::backportPP::Boolean::VERSION = '4.06';
+$JSON::backportPP::Boolean::VERSION = '4.07';
1;
diff --git a/t/107_allow_singlequote.t b/t/107_allow_singlequote.t
index c7bec6c..122c7b4 100644
--- a/t/107_allow_singlequote.t
+++ b/t/107_allow_singlequote.t
@@ -1,6 +1,6 @@
use Test::More;
-use strict;
+use strict;
use warnings;
BEGIN { plan tests => 4 };
BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; }
diff --git a/t/119_incr_parse_utf8.t b/t/119_incr_parse_utf8.t
new file mode 100644
index 0000000..182a5c6
--- /dev/null
+++ b/t/119_incr_parse_utf8.t
@@ -0,0 +1,77 @@
+use strict;
+use warnings;
+use Test::More tests => 24;
+
+use utf8;
+BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; }
+
+use JSON;
+use Encode;
+use charnames qw< :full >;
+
+use vars qw< @vs >;
+
+############################################################
+### These first tests mimic the ones in `t/001_utf8.t` ###
+############################################################
+
+scalar eval { JSON->new->allow_nonref (1)->utf8 (1)->incr_parse ('"ü"') };
+like $@, qr/malformed UTF-8/;
+
+ok (JSON->new->allow_nonref (1)->incr_parse ('"ü"') eq "ü");
+ok (JSON->new->allow_nonref (1)->incr_parse ('"\u00fc"') eq "ü");
+ok (JSON->new->allow_nonref (1)->incr_parse ('"\ud801\udc02' . "\x{10204}\"") eq "\x{10402}\x{10204}");
+ok (JSON->new->allow_nonref (1)->incr_parse ('"\"\n\\\\\r\t\f\b"') eq "\"\012\\\015\011\014\010");
+
+
+my $JSON_TXT = <<JSON_TXT;
+{ "a": "1" }
+{ "b": "\N{BULLET}" }
+{ "c": "3" }
+JSON_TXT
+
+#######################
+### With '->utf8' ###
+#######################
+
+@vs = eval { JSON->new->utf8->incr_parse( $JSON_TXT ) };
+like $@, qr/Wide character in subroutine entry/;
+
+
+@vs = eval { JSON->new->utf8->incr_parse( encode 'UTF-8' => $JSON_TXT ) };
+
+ok( !$@ );
+ok( scalar @vs == 3 );
+
+is_deeply( \@vs, [ { a => "1" }, { b => "\N{BULLET}" }, { c => "3" } ] );
+is_deeply( $vs[0], { a => "1" } );
+is_deeply( $vs[1], { b => "\N{BULLET}" } );
+is_deeply( $vs[2], { c => "3" } );
+
+
+# Double-Encoded => "You Get What You Ask For"
+
+@vs = eval { JSON->new->utf8->incr_parse( encode 'UTF-8' => ( encode 'UTF-8' => $JSON_TXT ) ) };
+
+ok( !$@ );
+ok( scalar @vs == 3 );
+
+is_deeply( \@vs, [ { a => "1" }, { b => "\x{E2}\x{80}\x{A2}" }, { c => "3" } ] );
+is_deeply( $vs[0], { a => "1" } );
+is_deeply( $vs[1], { b => "\x{E2}\x{80}\x{A2}" } );
+is_deeply( $vs[2], { c => "3" } );
+
+
+##########################
+### Without '->utf8' ###
+##########################
+
+@vs = eval { JSON->new->incr_parse( $JSON_TXT ) };
+
+ok( !$@ );
+ok( scalar @vs == 3 );
+
+is_deeply( \@vs, [ { a => "1" }, { b => "\N{BULLET}" }, { c => "3" } ] );
+is_deeply( $vs[0], { a => "1" } );
+is_deeply( $vs[1], { b => "\N{BULLET}" } );
+is_deeply( $vs[2], { c => "3" } );
diff --git a/t/rt_122270_is_bool_for_obsolete_xs_boolean.t b/t/rt_122270_is_bool_for_obsolete_xs_boolean.t
new file mode 100644
index 0000000..64fad70
--- /dev/null
+++ b/t/rt_122270_is_bool_for_obsolete_xs_boolean.t
@@ -0,0 +1,33 @@
+# copied over from JSON::XS and modified to use JSON
+
+use strict;
+use warnings;
+use Test::More;
+BEGIN { plan tests => 10 };
+
+BEGIN { $ENV{PERL_JSON_BACKEND} ||= "JSON::backportPP"; }
+
+use utf8;
+use JSON;
+
+SKIP: {
+ skip "no JSON::XS < 3", 5 unless eval { require JSON::XS; JSON::XS->VERSION < 3 };
+
+ my $false = JSON::XS::false();
+ ok (JSON::is_bool $false);
+ ok (++$false == 1);
+ ok (!JSON::is_bool $false);
+ ok (!JSON::is_bool "JSON::Boolean");
+ ok (!JSON::is_bool {}); # GH-34
+}
+
+SKIP: {
+ skip "no Types::Serialiser 0.01", 5 unless eval { require JSON::XS; JSON::XS->VERSION(3.00); require Types::Serialiser; Types::Serialiser->VERSION == 0.01 };
+
+ my $false = JSON::XS::false();
+ ok (JSON::is_bool $false);
+ ok (++$false == 1);
+ ok (!JSON::is_bool $false);
+ ok (!JSON::is_bool "JSON::Boolean");
+ ok (!JSON::is_bool {}); # GH-34
+}