Skip to content

Commit

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

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 authored and bighappyface committed Oct 10, 2017
1 parent 7ccb0e6 commit 0d4fda8
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 0d4fda8

Please sign in to comment.