Skip to content

fix(core): match see_also URLs with an uppercase scheme - #438

Merged
plusky merged 1 commit into
plusky:mainfrom
scarabeusiv:ocr-audit-fixes
Nov 20, 2026
Merged

plusky merged 1 commit into
plusky:mainfrom
scarabeusiv:ocr-audit-fixes

Conversation

@scarabeusiv

Copy link
Copy Markdown
Contributor

An OCR audit of the repository found one guard bug.

Guard::see_also_local_id stripped the URL scheme case-sensitively
before lowercasing, so a see_also link with an uppercase scheme
(HTTP://...) kept its scheme and the host prefix never matched. A
link to a bug the policy hides was then served unscrubbed. The same
lowercase-first ordering is applied to the base-URL strip in
embedded_local_ids, where an uppercase scheme in the configured
base URL broke matching against embedded URLs using another scheme.

Fix: lowercase first, then strip the scheme, in both places. The
existing see_also test gains the uppercase-scheme entries; it fails
on the old code and passes with the fix (I14).

Verification: full workspace gate green — cargo fmt --check,
cargo clippy (workspace and --features gen), cargo doc
(workspace and --features gen), cargo test --workspace --all-targets (26 test groups, 0 failures), cargo test --workspace --doc, cargo deny check.

see_also_local_id stripped the scheme case-sensitively before
lowercasing, so an uppercase scheme (HTTP://...) survived the strip
and the host prefix never matched. A see_also link to a hidden bug
written that way was served unscrubbed, disclosing the bug (I14).
Lowercase first, then strip the scheme; same for the base-URL strip
in embedded_local_ids.

@plusky plusky left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Approve — aggregated OCR + adversarial review (single review as requested).

OCR (native, range d769b88..bf2a7d1): 0 findings, 1 file reviewed.

Adversarial pass (I14 scrub path), all verified:

  • Fail-before proven locally: reverted the two closures to strip-then-lowercase with the new test entries kept — HTTP://bugzilla.example.com/show_bug.cgi?id=7 returns None instead of Some(7), exactly the leak described. Fix restored, all 87 guard:: tests green.
  • Safe direction: both functions feed I14 id collection for scrubbing, so the change only ADDS matches for genuinely-local URLs. Lowercasing before matching is DNS-correct; path matching is unchanged (the whole value was already lowercased after the strip).
  • Decision-only fold: matching runs on the lowercased copy; ids are collected, original text untouched, and to_ascii_lowercase is length-preserving so indices stay valid.
  • Degenerate base: embedded_local_ids keeps its base.is_empty() early return (fail-closed); see_also_local_id with a scheme-only base can only match a bare-path entry, which errs toward scrubbing, and such a base breaks all requests anyway.
  • No DESIGN update needed: no stamped claims cover strip ordering; this is a pure bug fix with a pinning test.

All 19 CI checks green. Merging.

@plusky
plusky merged commit 7bab7fc into plusky:main Nov 20, 2026
19 checks passed
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.

2 participants