Skip to content

fix(crossref): normalize DOI resolver URLs - #14606

Merged
kodjima33 merged 1 commit into
BasedHardware:mainfrom
cuentapraces07-ops:bounty-14523-crossref-normalize
Sep 19, 2026
Merged

kodjima33 merged 1 commit into
BasedHardware:mainfrom
cuentapraces07-ops:bounty-14523-crossref-normalize

Conversation

@cuentapraces07-ops

@cuentapraces07-ops cuentapraces07-ops commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #14523

Summary

  • Normalize bare DOI values, doi: identifiers, and doi.org/dx.doi.org resolver URLs before Crossref lookup.
  • Strip resolver query strings and fragments, decode the resolver path exactly once, and reject unrelated hosts, credentials, malformed values, and double-encoded paths.
  • Add 18 hermetic HTTP-boundary regression tests.

Verification

  • python plugins/omi-crossref-app/test_doi_normalization.py — 18/18 passed.
  • python .github/scripts/run_checks.py --lane local --check-id crossref-doi-normalization-tests — passed; manifest checks passed.
  • python -m compileall -q plugins/omi-crossref-app — passed.
  • git diff --check — clean.

Failure-Class: none

Bounty

The issue proposes US$25. Award and payment remain subject to maintainer review and the repository's terms; no payment is represented as guaranteed.

Disclosure

AI-assisted work, reviewed locally; no credentials, private data, or live network access were used by the tests.

Review in cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Reviewed against #14523 - the normalization is correct and security-reducing. Thanks for the well-scoped change and the hermetic test suite (18/18 pass locally, no network or extra deps needed).

File-by-file:

  • plugins/omi-crossref-app/main.py - normalize_doi() is the right shape for this boundary: strict doi.org/dx.doi.org host allowlist (case-insensitive, trailing-dot tolerated), scheme limited to http/https, credentials and non-default ports rejected, query/fragment discarded before a single unquote, and the result re-validated against _DOI_RE with .. rejected. Because the request site still applies quote(normalized, safe=''), a decoded / or # from a resolver path can never alter the request structure. get_crossref_work is the only DOI consumer in the file, so no other endpoint needed the change. Behavior notes worth having on record: + is not in the DOI charset (rare legacy 10.1000/158-style DOIs will now be rejected), and a bare DOI with internal whitespace errors instead of being sent as-is - both reasonable at a chat tool boundary.
  • plugins/omi-crossref-app/test_doi_normalization.py - good hermetic setup: fastapi/httpx/models stubbed via patch.dict(sys.modules), so the suite runs with stdlib only. The HttpBoundaryTests assertions pin the exact requested path (e.g. /works/10.5555%2Fa%2Fb%23c with query and fragment stripped) and verify invalid inputs never reach crossref_get, so they test the actual fix rather than just the helper. One optional addition: a bare DOI with an embedded space to document that it now errors.
  • .github/checks-manifest.yaml - the new crossref-doi-normalization-tests entry follows the existing ms365/shopify pattern (python3, local+ci lanes, triggers covering the plugin dir and the manifest itself) and its reason string accurately cites [Bounty proposal] fix(crossref): normalize encoded DOI resolver URLs before lookup ($25 proposed) #14523.

Bounty note: this PR implements the fix proposed in #14523 by a different account; awarding is a maintainer decision, not part of this review.

Leaving for human maintainer review before merge (plugin-boundary sign-off plus the bounty decision); no blocking concerns from this pass.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution python labels Sep 18, 2026

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Scoped DOI normalization fix for #14523, 18 regression tests, CI green. 5/5.

@kodjima33
kodjima33 merged commit 7a8f95f into BasedHardware:main Sep 19, 2026
44 of 45 checks passed
aryanorastar added a commit that referenced this pull request Sep 22, 2026
## What changed and why

Follow-up to #14523. The resolver normalization from #14606 correctly
parses trusted `doi.org` URLs, but its DOI suffix grammar rejects
registered identifiers containing reserved characters such as `<` and
`>`, as well as encoded suffix characters such as `&`, `?`, `=`, `@`,
`+`, and `%`.

This rebased change keeps the hardened scheme, host, credential, port,
and decode-once checks already on `main`, while accepting visible
Unicode DOI suffix characters and legacy dotted registrant codes. It
rejects whitespace, controls, format code points, unassigned characters,
and non-ASCII prefix digits. The normalized DOI is still quoted with
`safe=""`, so reserved characters and traversal-like suffix text remain
inside one Crossref API path segment.

This is complementary to #13979: that PR handles malformed Crossref
response payloads and HTTP client pooling, while this PR covers DOI
input compatibility at the request boundary.

## Product invariants affected

none

## How it was verified

- `python plugins/omi-crossref-app/test_doi_normalization.py` — 26
passed.
- `python -m pytest plugins/omi-crossref-app -q --tb=short` — 33 passed.
- `python -m compileall -q plugins/omi-crossref-app` — passed.
- `git diff --check` — no whitespace errors.
- Live Crossref lookup of registered DOI
`10.1002/1097-4636(200108)56:2<297::aid-jbm1098>3.0.co;2-s` returned
HTTP 200 and the expected work when the DOI was quoted as one path
segment.

The full manifest preflight cannot resolve in this sparse checkout
because unrelated manifest paths under backend, mobile, web, and desktop
are absent. The selected hermetic Crossref command and the complete
plugin suite pass directly.

## Tests

`plugins/omi-crossref-app/test_doi_normalization.py` now covers encoded
reserved suffix characters, exact-once decoding with a remaining literal
percent escape, legacy dotted registrant codes, a real registered DOI
containing angle brackets, visible Unicode suffixes, rejected
control/format/unassigned code points, rejected non-ASCII prefix digits,
repeated-dot suffixes, and the exact outbound quoted Crossref path.

## Backend Hermetic Merge Gate

Out of scope: this change only touches the Crossref plugin and its
existing hermetic DOI suite; it does not change backend, lockfile,
workflow, or gate paths.

## Failure class (fixes)

Failure-Class: FC-overstrict-identifier-grammar

## New guards

No new check is added. The existing `crossref-doi-normalization-tests`
manifest entry runs the extended behavioral suite and would catch the
over-restrictive DOI grammar.

The research, implementation, and tests were prepared with Codex
assistance on behalf of @dvdphobia.
@cuentapraces07-ops

Copy link
Copy Markdown
Contributor Author

Follow-up after the merge: the linked bounty issue proposed US$25, but the PR states that the award is subject to maintainer review. Could a maintainer confirm whether a reward was approved for this PR, the final amount, and the official private payout channel or instructions? I will not post any wallet or financial details publicly. Thank you.

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

Labels

positive-signal Automation verified a genuine fix/quality contribution python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bounty proposal] fix(crossref): normalize encoded DOI resolver URLs before lookup ($25 proposed)

3 participants