File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ public function getUriRetriever()
102
102
public function resolve ($ schema , $ sourceUri = null )
103
103
{
104
104
if (self ::$ depth > self ::$ maxDepth ) {
105
+ self ::$ depth = 0 ;
105
106
throw new JsonDecodingException (JSON_ERROR_DEPTH );
106
107
}
107
108
++self ::$ depth ;
Original file line number Diff line number Diff line change 9
9
10
10
namespace JsonSchema \Tests ;
11
11
12
+ use JsonSchema \Exception \JsonDecodingException ;
13
+
12
14
/**
13
15
* @group RefResolver
14
16
*/
@@ -355,4 +357,27 @@ public function testMaxDepthExceeded()
355
357
356
358
$ resolver ->resolve ($ jsonSchema );
357
359
}
360
+
361
+ public function testDepthRestoration ()
362
+ {
363
+ // stub schema
364
+ $ jsonSchema = new \stdClass ;
365
+ $ jsonSchema ->id = 'stub ' ;
366
+ $ jsonSchema ->additionalItems = new \stdClass ();
367
+ $ jsonSchema ->additionalItems ->additionalItems = 'stub ' ;
368
+
369
+ // stub resolver
370
+ \JsonSchema \RefResolver::$ maxDepth = 1 ;
371
+ $ resolver = new \JsonSchema \RefResolver ();
372
+
373
+ try {
374
+ $ resolver ->resolve ($ jsonSchema );
375
+ } catch (JsonDecodingException $ e ) {
376
+
377
+ }
378
+
379
+ $ reflection = new \ReflectionProperty ('\JsonSchema\RefResolver ' , 'depth ' );
380
+ $ reflection ->setAccessible (true );
381
+ $ this ->assertEquals (0 , $ reflection ->getValue ());
382
+ }
358
383
}
You can’t perform that action at this time.
0 commit comments