diff --git a/src/JsonSchema/Uri/UriRetriever.php b/src/JsonSchema/Uri/UriRetriever.php index df3afb1e..4fe696ae 100644 --- a/src/JsonSchema/Uri/UriRetriever.php +++ b/src/JsonSchema/Uri/UriRetriever.php @@ -276,7 +276,7 @@ private static function combineRelativePathWithBasePath($relativePath, $basePath preg_match('|^/?(\.\./(?:\./)*)*|', $relativePath, $match); $numLevelUp = strlen($match[0]) /3 + 1; if ($numLevelUp >= count($basePathSegments)) { - throw new UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath)); + throw new \JsonSchema\Exception\UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath)); } $basePathSegments = array_slice($basePathSegments, 0, -$numLevelUp); diff --git a/tests/JsonSchema/Tests/Uri/UriRetrieverTest.php b/tests/JsonSchema/Tests/Uri/UriRetrieverTest.php index 823e25a2..7409fd23 100644 --- a/tests/JsonSchema/Tests/Uri/UriRetrieverTest.php +++ b/tests/JsonSchema/Tests/Uri/UriRetrieverTest.php @@ -222,4 +222,15 @@ public function testResolvePointerFragmentNoArray() $schema, 'http://example.org/schema.json#/definitions/foo' ); } + + /** + * @expectedException JsonSchema\Exception\UriResolverException + */ + public function testResolveExcessLevelUp() + { + $retriever = new \JsonSchema\Uri\UriRetriever(); + $retriever->resolve( + '../schema.json#', 'http://example.org/schema.json#' + ); + } }