Skip to content

Commit

Permalink
Merge pull request #106 from openfryer/uriretriever-uriresolverexception
Browse files Browse the repository at this point in the history
Fix UriRetriever::combineRelativePathWithBasePath() does not qualify UriResolverException
  • Loading branch information
justinrainbow committed Aug 25, 2014
2 parents d98033f + 150cbae commit 87b54b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/JsonSchema/Uri/UriRetriever.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions tests/JsonSchema/Tests/Uri/UriRetrieverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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#'
);
}
}

0 comments on commit 87b54b4

Please sign in to comment.