fix: several host, IPv6, IDNA, and resolver correctness fixes - #68
Merged
Conversation
The KDoc on line 75 incorrectly described the old, buggy order: "lowercase then triplet rules". The fix (commit 3c86841) reordered the implementation to triplet/decode rules first, then lowercase. Update the comment to accurately reflect the new correct order: [NORM-6] uppercase triplets and [NORM-8] decode unreserved octets, followed by [NORM-5] lowercase letters. Also fix the incorrect NORM tag reference ([NORM-7] → [NORM-8]).
RFC 3986's IPv6address ABNF has no production for eight explicit groups followed by ::. The fix adds a guard clause to finish() that fails when a :: is present with all eight piece slots already written, preventing malformed literals like [1:2:3:4:5:6:7::8] from being incorrectly accepted.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…per @ The KDoc read as if the validation error were recorded once for every `@` consumed while splitting userinfo, but the parser only ever adds one entry per authority parse, regardless of how many `@` characters the userinfo span contains (a non-final `@` is folded into the username instead of producing its own entry).
The string-form Resolver.resolve(String, String) already had a test for the oversized-merge case returning ParseResult.Err instead of throwing, but the structured Resolver.resolve(ParsedComponents, ParsedComponents) overload shares the same transformReferences/mergedPath machinery and had no equivalent coverage.
This was referenced Jul 13, 2026
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.
Summary
Seven independent, narrowly-scoped fixes found while reviewing the parser/serializer/resolver code against RFC 3986, WHATWG URL, and UTS-46. Each is a separate commit with its own test.
Urireg-name normalization lowercased letters before decoding percent-encoded unreserved octets, so a percent-encoded uppercase letter (%41) never got folded —http://%41.com/normalized tohttp://A.com/instead ofhttp://a.com/, and re-normalizing the result changed it again. Decoding now runs before lowercasing.::with no gap. TheUri-profile IPv6 scanner accepted a::compression marker even when all eight groups were already explicit (e.g.[1:2:3:4:5:6:7::8]), silently treating it as equivalent to the same address with no compression. RFC 3986'sIPv6addressgrammar has no such production; this case is now rejected.invalid-credentialsvalidation error. The WHATWG parser records non-fatal validation errors for a handful of quirky-but-accepted inputs (backslash-as-solidus, missing authority slashes, etc.), but never recorded one for userinfo (user:pass@) in the authority, even though the spec calls for it. Parsed output is unaffected;validationErrors()now includes it.toJavaUri()had no total counterpart. Bridging aUrl/Uritojava.net.URIcan throw an uncheckedIllegalArgumentExceptionwhen the WHATWG grammar accepts something the older RFC 2396 grammarjava.net.URIuses does not (e.g. a literal|in a path). AddedtoJavaUriOrNull()for both types alongside the existing throwing form.xn--label as-is rather than rejecting it (existing browsers do this for compatibility). But that leniency was gated on the entire domain being ASCII, soxn--a.examplekept a bad label while the otherwise-identicalxn--a.caférejected the whole domain over the same label, just because a sibling label happened to be non-ASCII. The decision is now made per label, which is what the leniency was actually meant to describe.//, recomposition didn't guard it the way the rest of the serializer does, so it silently re-parsed as if an authority were present; (2) merging a base's directory prefix with a long relative reference could exceed an internal length bound and throw a raw exception straight out ofresolveOrNull/relativize, both of which are documented to never throw. Recomposition now applies the same guard used elsewhere, and the oversized-merge case now returns a proper error instead of throwing.ValidationErrorcase, the twotoJavaUriOrNullfunctions); the binary-compatibility snapshot has been regenerated to match.Test plan
:kuri:jvmTest :kuri:ktlintCheck :kuri:detekt :kuri:apiCheckgreen:kuri:jsNodeTestand:kuri:wasmJsNodeTestgreen:kuri:macosArm64Test(native) green; every other native target's test code compiles cleanly