json-schema icon indicating copy to clipboard operation
json-schema copied to clipboard

uri format does not accept all valid URIs

Open guidokessels opened this issue 11 years ago • 6 comments

Per https://tools.ietf.org/html/rfc3986#section-1.1.2 the following should all be valid, but they're not:

[PASS] ftp://ftp.is.co.za/rfc/rfc1808.txt
[PASS] http://www.ietf.org/rfc/rfc2396.txt
[PASS] ldap://[2001:db8::7]/c=GB?objectClass?one
[PASS] mailto:[email protected]
[PASS] news:comp.infosystems.www.servers.unix
[FAIL] tel:+1-816-555-1212
[PASS] telnet://192.0.2.16:80/
[FAIL] urn:oasis:names:specification:docbook:dtd:xml:4.1.2

This is due to the usage of FILTER_VALIDATE_URL in filter_var().

guidokessels avatar May 05 '15 09:05 guidokessels

just found "7://8" to be valid uri, by this validator. Don't be surprised. rfc3986 does not allow schema to start with digit, at least http://tools.ietf.org/html/rfc3986#appendix-A

vasili4 avatar Jul 17 '15 22:07 vasili4

I would still keep using filter_val, but report the bug to the PHP community and hope they fix filter_var. URL-testing is difficult. Also see: https://mathiasbynens.be/demo/url-regex

patricksavalle avatar Jul 20 '15 10:07 patricksavalle

Also failing are protocol-relative uris, which I had previously filed as #144.

legoktm avatar Aug 02 '15 21:08 legoktm

Closed with https://github.com/justinrainbow/json-schema/releases/tag/2.0.0

The relative URIs should be working but I am unsure if RFC3986 is supported per this issue. Please reopen if that is a problem with v2.0.0

bighappyface avatar Apr 14 '16 20:04 bighappyface

Hi, the urn: related URIs are still not validated properly, it is probably an issue in PHP itself, so I've opened a ticket there as well (https://bugs.php.net/bug.php?id=81332) but until it is not fixed there, maybe this library should look out for these kind of URIs.

tnagyce avatar Aug 05 '21 07:08 tnagyce

Okay it looks like PHP function actually validates the URL's properly, however, when the schema says it's an URI it should be validated against and URL and a URI as well, because there is some differences between the two.

tnagyce avatar Aug 05 '21 08:08 tnagyce