You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
uri, uri-reference, iri and iri-reference accept an invalid authority (port, userinfo, IP literal) #1389
The latest JSON-Schema-Test-Suite (json-schema-org/JSON-Schema-Test-Suite@e2a68a1, format-uri.json, format-uri-reference.json, format-iri.json, format-iri-reference.json) has new cases that master (74b7e58) and 1.5.9 both fail, with format assertions on. All of them accept an authority that RFC 3986 section 3.2 rejects:
format
input
expected
uri
http://example.com:abc/path
invalid: non-numeric port
uri
http://2001:0db8:85a3:0000:0000:8a2e:0370:7334
invalid: IPv6 without brackets
uri
http://[::ffff:01.2.3.4]
invalid: leading zero in embedded IPv4
uri-reference
//example.com:abc/p
invalid: non-numeric port
uri-reference
//a@b@example.com/
invalid: more than one @
uri-reference
//[::ffff:192.168.0.01]/p
invalid: leading zero in embedded IPv4
iri and iri-reference fail the same three kinds of case (non-numeric port, two @, leading zero in embedded IPv4), 12 cases in total.
I think the cause is in AbstractRFC3986Format: when java.net.URI can't parse the authority as server-based, it silently treats it as a registry-based authority, so the port, userinfo and host are never checked. URI.parseServerAuthority() isn't a fix on its own because it rejects valid reg-names such as a_b.example.
I'd like to send a PR that checks the authority against the RFC 3986 grammar in AbstractRFC3986Format (so all four formats get it), adds the new suite cases, and keeps http:// and about: valid (#1071).
One related question: UriFormatTest.noSchemeNoAuthorityShouldPass expects "//" to be a valid uri, but RFC 3986 section 3 requires a scheme for a URI ("//" is fine as a uri-reference). Should that change too, or stay as it is?
Activity