Hello community,

here is the log from the commit of package perl-JSON-Validator for 
openSUSE:Factory checked in at 2020-08-17 12:06:45
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-JSON-Validator (Old)
 and      /work/SRC/openSUSE:Factory/.perl-JSON-Validator.new.3399 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "perl-JSON-Validator"

Mon Aug 17 12:06:45 2020 rev:21 rq:827148 version:4.02

Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-JSON-Validator/perl-JSON-Validator.changes  
2020-07-05 01:19:59.613336233 +0200
+++ 
/work/SRC/openSUSE:Factory/.perl-JSON-Validator.new.3399/perl-JSON-Validator.changes
        2020-08-17 12:07:33.234766940 +0200
@@ -1,0 +2,10 @@
+Wed Aug 12 03:09:26 UTC 2020 - Tina Müller <timueller+p...@suse.de>
+
+- updated to 4.02
+   see /usr/share/doc/packages/perl-JSON-Validator/Changes
+
+  4.02 2020-08-11T13:06:40+0900
+   - Add recursive_data_protection() #220
+     Contributor: Jason Cooper
+
+-------------------------------------------------------------------

Old:
----
  JSON-Validator-4.01.tar.gz

New:
----
  JSON-Validator-4.02.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-JSON-Validator.spec ++++++
--- /var/tmp/diff_new_pack.iai88G/_old  2020-08-17 12:07:35.558768235 +0200
+++ /var/tmp/diff_new_pack.iai88G/_new  2020-08-17 12:07:35.562768238 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           perl-JSON-Validator
-Version:        4.01
+Version:        4.02
 Release:        0
 %define cpan_name JSON-Validator
 Summary:        Validate data against a JSON schema

++++++ JSON-Validator-4.01.tar.gz -> JSON-Validator-4.02.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.01/Changes 
new/JSON-Validator-4.02/Changes
--- old/JSON-Validator-4.01/Changes     2020-06-30 10:42:08.000000000 +0200
+++ new/JSON-Validator-4.02/Changes     2020-08-11 06:06:40.000000000 +0200
@@ -1,5 +1,9 @@
 Revision history for perl distribution JSON-Validator
 
+4.02 2020-08-11T13:06:40+0900
+ - Add recursive_data_protection() #220
+   Contributor: Jason Cooper
+
 4.01 2020-06-30T17:42:08+0900
  - Fix combining "allOf" and "not" #218
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.01/MANIFEST 
new/JSON-Validator-4.02/MANIFEST
--- old/JSON-Validator-4.01/MANIFEST    2020-06-30 10:42:10.000000000 +0200
+++ new/JSON-Validator-4.02/MANIFEST    2020-08-11 06:06:41.000000000 +0200
@@ -105,6 +105,7 @@
 t/load-yaml.t
 t/more-bundle.t
 t/random-errors.t
+t/recursive_data_protection.t
 t/relative-ref.t
 t/remotes/folder/folderInteger.json
 t/remotes/integer.json
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.01/META.json 
new/JSON-Validator-4.02/META.json
--- old/JSON-Validator-4.01/META.json   2020-06-30 10:42:09.000000000 +0200
+++ new/JSON-Validator-4.02/META.json   2020-08-11 06:06:41.000000000 +0200
@@ -63,6 +63,6 @@
       },
       "x_IRC" : "irc://irc.freenode.net/#mojo"
    },
-   "version" : "4.01",
+   "version" : "4.02",
    "x_serialization_backend" : "JSON::PP version 4.04"
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.01/META.yml 
new/JSON-Validator-4.02/META.yml
--- old/JSON-Validator-4.01/META.yml    2020-06-30 10:42:09.000000000 +0200
+++ new/JSON-Validator-4.02/META.yml    2020-08-11 06:06:41.000000000 +0200
@@ -32,5 +32,5 @@
   homepage: https://mojolicious.org
   license: http://www.opensource.org/licenses/artistic-license-2.0
   repository: https://github.com/mojolicious/json-validator.git
-version: '4.01'
+version: '4.02'
 x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.01/README.md 
new/JSON-Validator-4.02/README.md
--- old/JSON-Validator-4.01/README.md   2020-04-08 07:36:21.000000000 +0200
+++ new/JSON-Validator-4.02/README.md   2020-08-11 04:35:21.000000000 +0200
@@ -1,5 +1,5 @@
 
-# JSON::Validator [![Build 
Status](https://api.travis-ci.org/mojolicious/json-validator.svg?branch=master)](https://travis-ci.org/mojolicious/json-validator)
+# JSON::Validator
 
   A module for validating data against a [JSON 
Schema](https://json-schema.org/).
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.01/lib/JSON/Validator.pm 
new/JSON-Validator-4.02/lib/JSON/Validator.pm
--- old/JSON-Validator-4.01/lib/JSON/Validator.pm       2020-06-30 
10:42:08.000000000 +0200
+++ new/JSON-Validator-4.02/lib/JSON/Validator.pm       2020-08-11 
06:06:40.000000000 +0200
@@ -23,7 +23,7 @@
 use constant SPECIFICATION_URL => 'http://json-schema.org/draft-04/schema#';
 use constant YAML_SUPPORT      => eval 'use YAML::XS 0.67;1';
 
-our $VERSION = '4.01';
+our $VERSION = '4.02';
 our @EXPORT_OK = qw(joi validate_json);
 
 our %SCHEMAS = (
@@ -42,6 +42,8 @@
 
 has formats => sub { shift->_build_formats };
 
+has recursive_data_protection => 1;
+
 sub version {
   my $self = shift;
   Mojo::Util::deprecated('version() will be removed in future version.');
@@ -340,7 +342,7 @@
 
   my $tx  = $self->ua->get($url);
   my $err = $tx->error && $tx->error->{message};
-  confess "GET $url == $err"               if DEBUG and $err;
+  confess "GET $url == $err" if DEBUG and $err;
   die "[JSON::Validator] GET $url == $err" if $err;
 
   if ($cache_path
@@ -516,11 +518,11 @@
     last if !$ref or ref $ref;
     $fqn = $ref =~ m!^/! ? "#$ref" : $ref;
     my ($location, $pointer) = split /#/, $fqn, 2;
-    $url     = $location = _location_to_abs($location, $url);
+    $url = $location = _location_to_abs($location, $url);
     $pointer = undef if length $location and !length $pointer;
     $pointer = url_unescape $pointer if defined $pointer;
-    $fqn     = join '#', grep defined, $location, $pointer;
-    $other   = $self->_resolve($location);
+    $fqn   = join '#', grep defined, $location, $pointer;
+    $other = $self->_resolve($location);
 
     if (defined $pointer and length $pointer and $pointer =~ m!^/!) {
       $other = Mojo::JSON::Pointer->new($other)->get($pointer);
@@ -567,15 +569,18 @@
     if ref $schema eq 'HASH' and $schema->{'$ref'};
   return $schema ? () : E $path, [not => 'not'] if is_type $schema, 'BOOL';
 
-  my $seen_addr = join ':', refaddr($schema),
-    (ref $data ? refaddr $data : ++$self->{seen}{scalar});
+  my @errors;
+
+  if ($self->recursive_data_protection) {
+    my $seen_addr = join ':', refaddr($schema),
+      (ref $data ? refaddr $data : ++$self->{seen}{scalar});
 
-  # Avoid recursion
-  if ($self->{seen}{$seen_addr}) {
-    return @{$self->{seen}{$seen_addr}};
+    # Avoid recursion
+    return @{$self->{seen}{$seen_addr}} if $self->{seen}{$seen_addr};
+
+    $self->{seen}{$seen_addr} = \@errors;
   }
 
-  $self->{seen}{$seen_addr} = \my @errors;
   my $to_json
     = (blessed $data and $data->can('TO_JSON')) ? \$data->TO_JSON : undef;
   $data = $$to_json if $to_json;
@@ -899,7 +904,7 @@
   my @errors = $self->_validate_type_number($_[1], $path, $schema, 'integer');
 
   return @errors if @errors;
-  return         if $value =~ /^-?\d+$/;
+  return if $value =~ /^-?\d+$/;
   return E $path, [integer => type => data_type $value];
 }
 
@@ -1260,6 +1265,23 @@
 
 See L<JSON::Validator::Formats> for a list of supported formats.
 
+=head2 recursive_data_protection
+
+  my $jv = $jv->recursive_data_protections( $boolean );
+  my $boolean = $jv->recursive_data_protection;
+
+Recursive data protection is active by default, however it can be deactivated
+by assigning a false value to the L</recursive_data_protection> attribute.
+
+Recursive data protection can have a noticeable impact on memory usage when
+validating large data structures. If you are encountering issues with memory
+and you can guarantee that you do not have any loops in your data structure
+then deactivating the recursive data protection may help.
+
+This attribute is EXPERIMENTAL and may change in a future release.
+
+B<Disclaimer: Use at your own risk, if you have any doubt then don't use it>
+
 =head2 ua
 
   my $ua = $jv->ua;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/JSON-Validator-4.01/t/recursive_data_protection.t 
new/JSON-Validator-4.02/t/recursive_data_protection.t
--- old/JSON-Validator-4.01/t/recursive_data_protection.t       1970-01-01 
01:00:00.000000000 +0100
+++ new/JSON-Validator-4.02/t/recursive_data_protection.t       2020-08-11 
06:04:07.000000000 +0200
@@ -0,0 +1,46 @@
+use Mojo::Base -strict;
+use JSON::Validator;
+use Mojo::Util 'monkey_patch';
+use Scalar::Util qw(refaddr);
+use Test::More;
+
+my ($original_validate, %ref_counts) = (\&JSON::Validator::_validate);
+monkey_patch 'JSON::Validator', _validate => sub {
+  my ($self, $data, $path, $schema) = @_;
+  $ref_counts{refaddr($data)}++ if ref $data;
+  goto &$original_validate;
+};
+
+for ([1, 1], [0, 3]) {
+  my ($enabled, $exp_ref_counts) = @$_;
+  my $object = {level1 => {level2 => {level3 => 'Test'}}};
+  my $data   = [$object, $object, $object];
+
+  %ref_counts = ();
+
+  JSON::Validator->new->recursive_data_protection($enabled)->schema(schema())
+    ->validate($data);
+
+  is $ref_counts{refaddr($object->{level1}{level2})}, $exp_ref_counts,
+    "recursive_data_protection($enabled)";
+}
+
+done_testing;
+
+sub schema {
+  return {
+    type  => 'array',
+    items => {
+      type       => 'object',
+      properties => {
+        level1 => {
+          type       => 'object',
+          properties => {
+            level2 =>
+              {type => 'object', properties => {level3 => {type => 'string'}}}
+          }
+        }
+      }
+    }
+  };
+}


Reply via email to