Skip to content

fix: model Uri userinfo username/password as nullable#142

Open
OmarAlJarrah wants to merge 1 commit into
mainfrom
a5-uri-nullable-userinfo
Open

fix: model Uri userinfo username/password as nullable#142
OmarAlJarrah wants to merge 1 commit into
mainfrom
a5-uri-nullable-userinfo

Conversation

@OmarAlJarrah

Copy link
Copy Markdown
Member

Summary

  • ParsedComponents stored username/password as non-null strings defaulting to "", which collapsed "absent" and "present-but-empty" into the same value before serialization ever ran.
  • That broke the Uri PRESERVE profile's own documented equality contract: http://@h/ re-serialized to http://h/ (losing the @), and http://u:@h/ re-serialized to http://u@h/ (losing the trailing :), so two syntactically distinct URIs compared equal.
  • username/password are now modeled as String? through the parse pipeline: null means the component wasn't present at all, "" means it was present but empty. Uri's serializer (and therefore equals/hashCode, both derived from uriString), userInfo accessor, structured resolver, and normalizer all now preserve that distinction, and Uri.Builder round-trips it via newBuilder().build().
  • The Url (WHATWG) profile has no absent-vs-present-empty userinfo distinction in its own spec, so its parser, serializer, and public username/password accessors are unchanged in behavior (they still treat "" as absent).

Test plan

  • ./gradlew :kuri:jvmTest — new regression tests added to UriTest, UriParserTest, UriBuilderTest, UriBuilderUserInfoTest, and an existing ResolverTest case updated for the corrected behavior
  • ./gradlew :kuri:ktlintCheck
  • ./gradlew :kuri:detekt
  • ./gradlew :kuri:jvmApiCheck and ./gradlew :kuri:klibApiCheck — no public API shape change (ParsedComponents is internal), confirmed with no diff; androidApiCheck could not run in this environment (no Android SDK configured), which is a pre-existing environment gap unrelated to this change
  • ./gradlew :kuri:jsNodeTest (commonMain touched)
  • ./gradlew :kuri:macosArm64Test (native compile sanity check)
  • ./gradlew :kuri:koverVerifyJvm

Closes #104

…sence

ParsedComponents stored username and password as non-null strings defaulting
to "", so an absent userinfo/password and a present-but-empty one collapsed
to the same value before serialization ever ran. That broke the Uri PRESERVE
profile's own equality contract: "http://@h/" re-serialized to "http://h/"
(losing the "@") and "http://u:@h/" re-serialized to "http://u@h/" (losing
the trailing ":"), so URIs that are syntactically different compared equal.

Model username/password as String? through the parse pipeline instead: null
means the component wasn't present at all, "" means it was present but
empty. The Uri profile's serializer, equals/hashCode (both derived from
uriString), userInfo accessor, structured resolver, and normalizer now all
preserve that distinction. The Url (WHATWG) profile has no such distinction
in its own spec, so its parser, serializer, and public username/password
accessors keep treating "" as absent, unchanged in behavior.

Closes #104
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kuri: Uri PRESERVE profile cannot distinguish absent userinfo/password from empty userinfo/password

1 participant