Skip to content

Commit

Permalink
Don't add a file:// prefix to URI that already have a scheme (jsonr…
Browse files Browse the repository at this point in the history
…ainbow#455)

Some URI types do not pass validation against \FILTER_VAR_URL (e.g.
phar://), but are still valid and still have a scheme. This patch
catches those situations via a simple regex.
  • Loading branch information
erayd committed Oct 10, 2017
1 parent 7ccb0e6 commit bc5ad56
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/JsonSchema/Uri/UriResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ public function generate(array $components)
public function resolve($uri, $baseUri = null)
{
// treat non-uri base as local file path
if (!is_null($baseUri) && !filter_var($baseUri, \FILTER_VALIDATE_URL)) {
if (
!is_null($baseUri) &&
!filter_var($baseUri, \FILTER_VALIDATE_URL) &&
!preg_match('|^[^/]+://|u', $baseUri)
) {
if (is_file($baseUri)) {
$baseUri = 'file://' . realpath($baseUri);
} elseif (is_dir($baseUri)) {
Expand Down

0 comments on commit bc5ad56

Please sign in to comment.