Repository navigation
Fix iri, iri-reference, uri and uri-reference - #1071
Merged
Merged
Conversation
This was referenced Nov 18, 2026
stevehu
pushed a commit
that referenced
this pull request
Nov 20, 2026
* Check the authority of uri, uri-reference, iri and iri-reference java.net.URI falls back to a registry-based authority when it cannot parse the authority as a server, and then checks neither the port, the userinfo nor the host. So http://example.com:abc/path, //a@b@example.com/, http://[::ffff:01.2.3.4] and an IPv6 address without brackets were accepted. AbstractRFC3986Format now checks a parsed authority against RFC 3986 section 3.2 for all four formats: the port is digits only, the userinfo holds no other "@", the host is a reg-name or an IPv6 literal without leading zeros in an embedded IPv4 address (reusing the ipv6 pattern), and the IRI formats also allow RFC 3987 ucschar in the userinfo and the host. URI#parseServerAuthority() is not used because it rejects valid reg-names such as a_b.example. http:// and about: (#1071) stay valid. Add the 12 failing JSON-Schema-Test-Suite cases to the vendored uri, uri-reference, iri and iri-reference suite files (draft 6, 7, 2019-09, 2020-12 and draft-next) and a unit test for the edge cases. Closes #1389 * Address review: IRI hosts, bidi characters, zone ids and cleanup - IriFormat and IriReferenceFormat no longer run the IPv6 pattern on the decoded authority, which rejected a valid reg-name such as 1%3A%3A2. The port check already rejects an IPv6 address without brackets. - The IRI formats reject the bidirectional formatting characters U+200E, U+200F and U+202A to U+202E in the userinfo and the host (RFC 3987 section 4.1). - The bracketed host is checked with a new IPv6Format.isValid, shared with the ipv6 format, instead of a copy of its checks. The branches for a missing "]" and for the port after "]" are removed: java.net.URI only returns a bracketed host after a successful server parse. - UriAuthorityFormatTest drops two rows that never reached the new code and covers the cases above. - The uri cases are added to the draft 3 and draft 4 suite files too. - CHANGELOG: zone ids are now rejected, iri and iri-reference already rejected an IPv6 address without brackets, and third-party subclasses of AbstractRFC3986Format get the check and the isInternationalized() hook. * Reject bidi formatting characters anywhere in an IRI RFC 3987 section 4.1 forbids the bidirectional formatting characters U+200E, U+200F and U+202A to U+202E anywhere in an IRI, not only in the authority. iri and iri-reference now reject them in the path, the query and the fragment too; the check moves from ucschar to the whole value. The CHANGELOG example for a second "@" now uses an absolute URI, and an unrelated whitespace change is reverted. * Address review: guard the IPv6 bracket, wider bidi set, IRI-only bidi check - The bracketed host check returns false instead of throwing if no "]" follows the "[". - The IRI formats also reject U+061C (ALM) and the isolates U+2066 to U+2069, which can reorder the displayed text like the RFC 3987 list. - The bidi check moves into IriFormat and IriReferenceFormat, so isInternationalized() controls only ucschar in the userinfo and host. It scans with a charAt loop. - The draft 3 suite change is reverted: draft 3 has no runner. - Tests cover bidi in the userinfo, a percent-encoded bidi character, and the added characters. The CHANGELOG is updated. * Make containsBidiFormatting available to IRI-like subclasses Address review: a subclass of AbstractRFC3986Format in another package for an IRI-like format can now call containsBidiFormatting from its validate(), and the CHANGELOG says it should.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1070
This fixes
iri,iri-reference,urianduri-referenceformats to allow inputs conforming to RFC 3986 / RFC 3987 for whichURIwill throw a syntax error as it implements RFC 2396.In particular inputs like
http://,//andabout:are now accepted.A more complete and proper fix will likely require an additional library like Apache Jena IRI but will defer this until it is really needed.