Skip to content

Commit 97cbe5d

Browse files
committed
Merge branch 'pull-71'
* pull-71: HACK: limit recursive expansion to 7 levels
2 parents 48bd037 + c543029 commit 97cbe5d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/JsonSchema/RefResolver.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
*/
2222
class RefResolver
2323
{
24+
/**
25+
* HACK to prevent too many recursive expansions.
26+
* Happens e.g. when you want to validate a schema against the schema
27+
* definition.
28+
*
29+
* @var integer
30+
*/
31+
protected static $depth = 0;
32+
2433
/**
2534
* @var UriRetrieverInterface
2635
*/
@@ -81,7 +90,13 @@ public function getUriRetriever()
8190
*/
8291
public function resolve($schema, $sourceUri = null)
8392
{
93+
if (self::$depth > 7) {
94+
return;
95+
}
96+
++self::$depth;
97+
8498
if (! is_object($schema)) {
99+
--self::$depth;
85100
return;
86101
}
87102

@@ -109,6 +124,8 @@ public function resolve($schema, $sourceUri = null)
109124
foreach (array('dependencies', 'patternProperties', 'properties') as $propertyName) {
110125
$this->resolveObjectOfSchemas($schema, $propertyName, $sourceUri);
111126
}
127+
128+
--self::$depth;
112129
}
113130

114131
/**

0 commit comments

Comments
 (0)