Description
Hi guys..
First, thanks for the active work on this project, it's very nice to see that much activity going on here ,-)
An update from 5.1.0
to 5.2.0
broke one of our projects unit tests and i'm not sure if our test expectations are wrong - or the changes here ;-)
The schema
Given this simple schema:
{
"title": "Example",
"type": "object",
"properties": {
"url": {
"title": "Url",
"type": [
"string",
"null"
],
"format": "uri"
}
},
"additionalProperties": false
}
The problem
Our unit tests expects the string jjj--no-url
not to be a valid url.. but apparently now, it is ;-)
This was changed recently in commit 5e92df0
For us, this is kinda of a problem, we don't regard (and who would?) jjj--no-url
as a valid url..
So if i pass the string jjj--no-url
as an url, it will land in this condition of the if
:
https://github.com/justinrainbow/json-schema/blob/5.2.0/src/JsonSchema/Constraints/FormatConstraint.php#L96
The question
Isn't the check to lean? If we have a look at the line:
$validURL = filter_var('scheme://host/' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
So this basically means that any string will pass (as long it doesn't have invalid filename parts) as it gets prefixed with a scheme and a host (thus seen as a relative part)..
I checked this, even the string a
will pass.
IMHO, this makes the uri
check obsolete and wrong. If we prepend scheme and host for the user to pass the url check, the user really didn't provide a correct url..
So is this what is really expected, that any string passes the uri
format?
Thanks ;-)