Skip to content

Fix Authority comparison ignoring userinfo case - #891

Open
draarivpatel-ui wants to merge 1 commit into
hyperium:masterfrom
draarivpatel-ui:fix-authority-userinfo-case
Open

draarivpatel-ui wants to merge 1 commit into
hyperium:masterfrom
draarivpatel-ui:fix-authority-userinfo-case

Conversation

@draarivpatel-ui

Copy link
Copy Markdown

Summary

PartialEq, PartialOrd, and Hash for http::uri::Authority compared the entire authority string case-insensitively. Per RFC 3986 Section 6.2.2.1 only the host subcomponent is case-insensitive; the userinfo subcomponent is case-sensitive, so authorities differing only in userinfo case must not compare equal.

Change

Comparisons and hashing now split the authority at the userinfo delimiter (the last @, which cannot appear unencoded in a valid host):

  • userinfo is compared byte-wise (case-sensitive)
  • the remainder (host and port) is compared case-insensitively, matching previous behavior
  • Hash is updated to stay consistent with PartialEq

All Authority/str/&str/String comparison impls route through the same helpers so cross-type comparisons behave identically.

Test plan

  • New unit tests cover userinfo case-sensitivity, continued host case-insensitivity with userinfo present, and hash consistency with equality
  • cargo test passes (152 lib + 228 doc + integration tests), cargo fmt --check clean

Fixes #625

The PartialEq, PartialOrd and Hash implementations for Authority
compared the entire authority string case-insensitively. Per RFC 3986
Section 6.2.2.1 only the host subcomponent is case-insensitive; the
userinfo subcomponent is case-sensitive, so two authorities differing
only in userinfo case must not compare equal.

Split the authority at the userinfo delimiter for equality, ordering
and hashing: userinfo is compared and hashed byte-wise, the remainder
case-insensitively as before.

Fixes hyperium#625
Copilot AI balanced review requested due to automatic review settings November 25, 2026 21:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

No deployments
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.

PartialEq/Ord impls for Authority ignores case of userinfo part

2 participants