Skip to content

Commit 87b54b4

Browse files
committed
Merge pull request #106 from openfryer/uriretriever-uriresolverexception
Fix UriRetriever::combineRelativePathWithBasePath() does not qualify UriResolverException
2 parents d98033f + 150cbae commit 87b54b4

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/JsonSchema/Uri/UriRetriever.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ private static function combineRelativePathWithBasePath($relativePath, $basePath
276276
preg_match('|^/?(\.\./(?:\./)*)*|', $relativePath, $match);
277277
$numLevelUp = strlen($match[0]) /3 + 1;
278278
if ($numLevelUp >= count($basePathSegments)) {
279-
throw new UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath));
279+
throw new \JsonSchema\Exception\UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath));
280280
}
281281

282282
$basePathSegments = array_slice($basePathSegments, 0, -$numLevelUp);

tests/JsonSchema/Tests/Uri/UriRetrieverTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,15 @@ public function testResolvePointerFragmentNoArray()
222222
$schema, 'http://example.org/schema.json#/definitions/foo'
223223
);
224224
}
225+
226+
/**
227+
* @expectedException JsonSchema\Exception\UriResolverException
228+
*/
229+
public function testResolveExcessLevelUp()
230+
{
231+
$retriever = new \JsonSchema\Uri\UriRetriever();
232+
$retriever->resolve(
233+
'../schema.json#', 'http://example.org/schema.json#'
234+
);
235+
}
225236
}

0 commit comments

Comments
 (0)