r50468 - in /branches/upstream/libjson-perl/current: Changes MANIFEST META.yml README lib/JSON.pm lib/JSON/PP.pm t/22_comment_at_eof.t

angelabad-guest at users.alioth.debian.org angelabad-guest at users.alioth.debian.org
Thu Jan 7 16:48:58 UTC 2010


Author: angelabad-guest
Date: Thu Jan  7 16:48:52 2010
New Revision: 50468

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=50468
Log:
[svn-upgrade] Integrating new upstream version, libjson-perl (2.17)

Added:
    branches/upstream/libjson-perl/current/t/22_comment_at_eof.t
Modified:
    branches/upstream/libjson-perl/current/Changes
    branches/upstream/libjson-perl/current/MANIFEST
    branches/upstream/libjson-perl/current/META.yml
    branches/upstream/libjson-perl/current/README
    branches/upstream/libjson-perl/current/lib/JSON.pm
    branches/upstream/libjson-perl/current/lib/JSON/PP.pm

Modified: branches/upstream/libjson-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/Changes?rev=50468&op=diff
==============================================================================
--- branches/upstream/libjson-perl/current/Changes (original)
+++ branches/upstream/libjson-perl/current/Changes Thu Jan  7 16:48:52 2010
@@ -12,6 +12,18 @@
      Please check JSON::RPC (supports JSON-RPC protocol v1.1 and 1.0).
 
 ##########################################################################
+
+ !! Since 2.16, PP's relaxed option caused an infinite loop in some condition.
+ !! Recommend to update old versions.
+
+2.17  Thu Jan  7 12:23:13 2010
+	[JSON]
+	- fixed a problem caused by JSON::XS backend and support_by_pp option
+	  (rt#52842,  rt#52847 by ikegami)
+	[JSON::PP]
+	- made compatible with JSON::XS 2.27
+	- patched decode for incr_parse (rt#52820 by ikegami)
+	- relaxed option caused an infinite loop in some condition.
 
 2.16  Fri Oct 16 15:07:37 2009
 	[JSON][JSON::PP]

Modified: branches/upstream/libjson-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/MANIFEST?rev=50468&op=diff
==============================================================================
--- branches/upstream/libjson-perl/current/MANIFEST (original)
+++ branches/upstream/libjson-perl/current/MANIFEST Thu Jan  7 16:48:52 2010
@@ -31,6 +31,7 @@
 t/19_incr.t
 t/20_unknown.t
 t/21_evans_bugrep.t
+t/22_comment_at_eof.t
 t/99_binary.t
 
 t/e00_func.t

Modified: branches/upstream/libjson-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/META.yml?rev=50468&op=diff
==============================================================================
--- branches/upstream/libjson-perl/current/META.yml (original)
+++ branches/upstream/libjson-perl/current/META.yml Thu Jan  7 16:48:52 2010
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               JSON
-version:            2.16
+version:            2.17
 abstract:           JSON (JavaScript Object Notation) encoder/decoder
 author:
     - Makamaka Hannyaharamitu, E<lt>makamaka[at]cpan.orgE<gt>

Modified: branches/upstream/libjson-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/README?rev=50468&op=diff
==============================================================================
--- branches/upstream/libjson-perl/current/README (original)
+++ branches/upstream/libjson-perl/current/README Thu Jan  7 16:48:52 2010
@@ -1,4 +1,4 @@
-JSON version 2.16
+JSON version 2.17
 =================
 
 INSTALLATION
@@ -42,9 +42,9 @@
      use JSON -support_by_pp;
 
 VERSION
-        2.16
-
-    This version is compatible with JSON::XS 2.26 and later.
+        2.17
+
+    This version is compatible with JSON::XS 2.27 and later.
 
 DESCRIPTION
      ************************** CAUTION ********************************

Modified: branches/upstream/libjson-perl/current/lib/JSON.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/lib/JSON.pm?rev=50468&op=diff
==============================================================================
--- branches/upstream/libjson-perl/current/lib/JSON.pm (original)
+++ branches/upstream/libjson-perl/current/lib/JSON.pm Thu Jan  7 16:48:52 2010
@@ -7,13 +7,13 @@
 @JSON::EXPORT = qw(from_json to_json jsonToObj objToJson encode_json decode_json);
 
 BEGIN {
-    $JSON::VERSION = '2.16';
+    $JSON::VERSION = '2.17';
     $JSON::DEBUG   = 0 unless (defined $JSON::DEBUG);
 }
 
 my $Module_XS  = 'JSON::XS';
 my $Module_PP  = 'JSON::PP';
-my $XS_Version = '2.26';
+my $XS_Version = '2.27';
 
 
 # XS and PP common methods
@@ -414,6 +414,7 @@
         bless  $proto, $pkg;
     };
 
+
     for my $method (@methods) {
         my $flag = uc($method);
         my $type |= (UNSUPPORTED_ENCODE_FLAG->{$flag} || 0);
@@ -441,9 +442,20 @@
 
 package JSON::Backend::XS::Supportable;
 
-
-my $JSON_XS_encode_orignal = \&JSON::XS::encode;
-my $JSON_XS_decode_orignal = \&JSON::XS::decode;
+{
+    my $JSON_XS_encode_orignal = \&JSON::XS::encode;
+    my $JSON_XS_decode_orignal = \&JSON::XS::decode;
+    my $JSON_XS_incr_parse_orignal = \&JSON::XS::incr_parse;
+
+    local $^W;
+    *JSON::XS::decode = \&JSON::Backend::XS::Supportable::_decode;
+    *JSON::XS::encode = \&JSON::Backend::XS::Supportable::_encode;
+    *JSON::XS::incr_parse = \&JSON::Backend::XS::Supportable::_incr_parse;
+
+    *{JSON::XS::_original_decode} = $JSON_XS_decode_orignal;
+    *{JSON::XS::_original_encode} = $JSON_XS_encode_orignal;
+    *{JSON::XS::_original_incr_parse} = $JSON_XS_incr_parse_orignal;
+}
 
 $Carp::Internal{'JSON::Backend::XS::Supportable'} = 1;
 
@@ -461,16 +473,6 @@
         else {
             ${$_[0]} &= ~$type;
         }
-
-        if (${$_[0]}) {
-            *JSON::XS::encode = \&JSON::Backend::XS::Supportable::_encode;
-            *JSON::XS::decode = \&JSON::Backend::XS::Supportable::_decode;
-        }
-        else {
-            *JSON::XS::encode = $JSON_XS_encode_orignal;
-            *JSON::XS::decode = $JSON_XS_decode_orignal;
-        }
-
         $_[0];
     };
 
@@ -507,19 +509,38 @@
     return $pp;
 }
 
-
 sub _encode { # using with PP encod
-    _set_for_pp('encode' => @_)->encode($_[1]);
+    if (${$_[0]}) {
+        _set_for_pp('encode' => @_)->encode($_[1]);
+    }
+    else {
+        $_[0]->_original_encode( $_[1] );
+    }
 }
 
 
 sub _decode { # if unsupported-flag is set, use PP
-    _set_for_pp('decode' => @_)->decode($_[1]);
+    if (${$_[0]}) {
+        _set_for_pp('decode' => @_)->decode($_[1]);
+    }
+    else {
+        $_[0]->_original_decode( $_[1] );
+    }
 }
 
 
 sub decode_prefix { # if unsupported-flag is set, use PP
     _set_for_pp('decode' => @_)->decode_prefix($_[1]);
+}
+
+
+sub _incr_parse {
+    if (${$_[0]}) {
+        _set_for_pp('decode' => @_)->incr_parse($_[1]);
+    }
+    else {
+        $_[0]->_original_incr_parse( $_[1] );
+    }
 }
 
 
@@ -586,9 +607,9 @@
 
 =head1 VERSION
 
-    2.16
-
-This version is compatible with JSON::XS B<2.26> and later.
+    2.17
+
+This version is compatible with JSON::XS B<2.27> and later.
 
 
 =head1 DESCRIPTION
@@ -2058,7 +2079,7 @@
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2005-2009 by Makamaka Hannyaharamitu
+Copyright 2005-2010 by Makamaka Hannyaharamitu
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself. 

Modified: branches/upstream/libjson-perl/current/lib/JSON/PP.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/lib/JSON/PP.pm?rev=50468&op=diff
==============================================================================
--- branches/upstream/libjson-perl/current/lib/JSON/PP.pm (original)
+++ branches/upstream/libjson-perl/current/lib/JSON/PP.pm Thu Jan  7 16:48:52 2010
@@ -11,7 +11,7 @@
 use B ();
 #use Devel::Peek;
 
-$JSON::PP::VERSION = '2.26000';
+$JSON::PP::VERSION = '2.27000';
 
 @JSON::PP::EXPORT = qw(encode_json decode_json from_json to_json);
 
@@ -707,7 +707,13 @@
                     : (!$octets[2]                ) ? 'UTF-32LE'
                     : 'unknown';
 
-        my $result = value();
+#        my $result = value();
+
+        my $eof = !( my ( $result ) = value() ); # $eof for incr_parse
+
+        if ( $eof && ( $opt & 0x00000001 ) ) {
+            return undef;
+        }
 
         if (!$idx->[ P_ALLOW_NONREF ] and !ref $result) {
                 decode_error(
@@ -891,7 +897,7 @@
             else{
                 if ($relaxed and $ch eq '#') { # correctly?
                     pos($text) = $at;
-                    $text =~ /\G([^\n]*(?:\r\n|\r|\n))/g;
+                    $text =~ /\G([^\n]*(?:\r\n|\r|\n|$))/g;
                     $at = pos($text);
                     next_chr;
                     next;
@@ -1227,9 +1233,6 @@
             $no_rep ? "$error" : "$error, at character offset $at (before \"$mess\")"
         );
 
-#        Carp::croak (
-#            $no_rep ? "$error" : "$error, at character offset $at [\"$mess\"]"
-#        );
     }
 
 
@@ -1341,6 +1344,8 @@
 use constant INCR_M_STR  => 1; # inside string
 use constant INCR_M_BS   => 2; # inside backslash
 use constant INCR_M_JSON => 3; # outside anything, count nesting
+use constant INCR_M_C0   => 4;
+use constant INCR_M_C1   => 5;
 
 $JSON::PP::IncrParser::VERSION = '1.01';
 
@@ -1450,6 +1455,12 @@
             elsif ( $s eq ']' or $s eq '}' ) {
                 last if ( --$self->{incr_nest} <= 0 );
             }
+            elsif ( $s eq '#' ) {
+                while ( $len > $p ) {
+                    last if substr( $text, $p++, 1 ) eq "\n";
+                }
+            }
+
         }
 
     }
@@ -2125,7 +2136,7 @@
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2007-2009 by Makamaka Hannyaharamitu
+Copyright 2007-2010 by Makamaka Hannyaharamitu
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself. 

Added: branches/upstream/libjson-perl/current/t/22_comment_at_eof.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libjson-perl/current/t/22_comment_at_eof.t?rev=50468&op=file
==============================================================================
--- branches/upstream/libjson-perl/current/t/22_comment_at_eof.t (added)
+++ branches/upstream/libjson-perl/current/t/22_comment_at_eof.t Thu Jan  7 16:48:52 2010
@@ -1,0 +1,47 @@
+# the oritinal test case was provided by IKEGAMI at cpan.org
+
+use strict;
+
+use Test::More tests => 13;
+
+BEGIN { $ENV{PERL_JSON_BACKEND} = 0; }
+
+use JSON;
+
+use Data::Dumper qw( Dumper );
+
+sub decoder {
+   my ($str) = @_;
+
+   my $json = JSON->new->relaxed;
+
+   $json->incr_parse($_[0]);
+
+   my $rv;
+   if (!eval { $rv = $json->incr_parse(); 1 }) {
+       $rv = "died with $@";
+   }
+
+   local $Data::Dumper::Useqq = 1;
+   local $Data::Dumper::Terse = 1;
+   local $Data::Dumper::Indent = 0;
+
+   return Dumper($rv);
+}
+
+
+is( decoder( "[]"        ), '[]', 'array baseline' );
+is( decoder( " []"       ), '[]', 'space ignored before array' );
+is( decoder( "\n[]"      ), '[]', 'newline ignored before array' );
+is( decoder( "# foo\n[]" ), '[]', 'comment ignored before array' );
+is( decoder( "# fo[o\n[]"), '[]', 'comment ignored before array' );
+is( decoder( "# fo]o\n[]"), '[]', 'comment ignored before array' );
+is( decoder( "[# fo]o\n]"), '[]', 'comment ignored inside array' );
+
+is( decoder( ""        ), 'undef', 'eof baseline' );
+is( decoder( " "       ), 'undef', 'space ignored before eof' );
+is( decoder( "\n"      ), 'undef', 'newline ignored before eof' );
+is( decoder( "#,foo\n" ), 'undef', 'comment ignored before eof' );
+is( decoder( "# []o\n" ), 'undef', 'comment ignored before eof' );
+
+is( decoder( qq/#\n[#foo\n"#\\n"#\n]/), '["#\n"]', 'array and string in multiple lines' );




More information about the Pkg-perl-cvs-commits mailing list