Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't add a file:// prefix to URI that already have a scheme #455

Merged
merged 1 commit into from
Oct 9, 2017

Conversation

erayd
Copy link
Contributor

@erayd erayd commented Oct 5, 2017

What

Add regex filter to URI check when expanding $ref.

Why

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.

Fixes #451.

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.
if (
!is_null($baseUri) &&
!filter_var($baseUri, \FILTER_VALIDATE_URL) &&
!preg_match('|^[^/]+://|u', $baseUri)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pipe | delimiter so that you do not need to escape the forward slash / characters, correct?

@erayd
Copy link
Contributor Author

erayd commented Oct 5, 2017

Yup. It looks neater, and it's easier for a human to quickly understand the regex at a glance.

@bighappyface bighappyface merged commit bbdb443 into jsonrainbow:6.0.0-dev Oct 9, 2017
erayd added a commit to erayd/json-schema that referenced this pull request Oct 10, 2017
…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.
@erayd erayd deleted the bugfix-451-phar branch October 10, 2017 05:53
bighappyface pushed a commit that referenced this pull request Oct 10, 2017
…#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants