Skip to content

fix(javascript): respect HTML base URL components - #589

Merged
morluto merged 3 commits into
morluto:mainfrom
rudycelekli:campaign/rea-html-base-20261005
Oct 5, 2026
Merged

morluto merged 3 commits into
morluto:mainfrom
rudycelekli:campaign/rea-html-base-20261005

Conversation

@rudycelekli

@rudycelekli rudycelekli commented Oct 5, 2026 •

Copy link
Copy Markdown

Summary

Ignore query and fragment components before computing the document base directory. Honor external and protocol-relative bases for root-relative HTML references; preserve existing artifact confinement and container identity.

No tracking issue: this is a focused correctness regression found through production-seam reproduction.

Problem and expected behavior

Local relationship resolution follows the HTML base URL pathname and origin; artifact containment and container identity remain enforced.

Change and scope

The change stays in the owning adapter/application stage and corrects existing behavior without adding tools or broadening provider coverage.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Application HTML-reference path resolution, before local-artifact relationship selection.
  • CLI and MCP/tool-catalog contract: existing schemas and tool inventory remain intact; corrected results flow through the owning operation.
  • Provider, bridge, target-format, or platform compatibility: Source-owned filesystem and native URL controls ran; browser navigation was not used to claim runtime execution of references.
  • Evidence, artifact, provenance, or reconstruction contract: Local relationship resolution follows the HTML base URL pathname and origin; artifact containment and container identity remain enforced.
  • Process execution, authorization, cleanup, or containment impact: Existing execution authority, cleanup and containment remain preserved.
  • Generated metadata, package, or installation impact: no metadata or dependency changes.

Evidence and regression coverage

Five base-revision failures; 53 focused path-resolution tests pass. Native Node URL controls cover query/fragment and external/protocol-relative bases.

Tests exercise production parsing, filesystem, HTTP, or browser seams, without module mocks. Evidence above is executed; unverified platform/provider coverage is stated explicitly.

Validation performed

All required local gates passed on the signed commit:

  • npm run check:pr
  • npm run check:ci
  • npm run verify:package
  • npm pack --dry-run

Development runtime: Node.js 24.18.0 and npm 11.16.0. Upstream CI is separate from these local results.

Compatibility, safety, and release

No migration or package dependency changes. Real Hopper/Ghidra verification was not run; this patch does not change those providers. Remaining proof limits are stated above. The final diff contains source and tests only.

Prepared with AI assistance.

Rudy Celekli and others added 2 commits October 5, 2026 12:04
…ntax

A relative HTML reference resolves against the base URL's directory, and that
directory drops a trailing "." or ".." segment rather than stepping through
it. Only a trailing "/" was treated as a directory, so <base href=".">
resolved against the artifact root instead of the document directory, and
<base href="sub/."> resolved against the parent of "sub".

The base href is also a second untrusted path input, but rejectDeclaration
only applied its admission rules to the declared path, so an encoded-traversal
or backslash base href relied on files-map confinement to stay safe. Both
inputs now share one admitsCanonicalPathSyntax predicate, and a local base
href is rejected with a reason naming the base href rather than a generic
declared-path message. External base hrefs are still reported as external,
so an encoded path on an unreachable origin keeps the more accurate reason.

7 of the new cases fail without this change.
@morluto

morluto commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Pushed 4d6d1f02 addressing the two notes from review. I re-ran a differential probe of 26 base/reference pairs against new URL() and confirmed every remaining divergence is an intentional design choice — external base to external, and artifact confinement.

<base href=".">. Confirmed as a real WHATWG divergence and fixed. The cause was that only a trailing / was treated as a directory. A base URL's directory drops a trailing . or .. segment rather than stepping through it, so:

base resolved before
. renderer/app.js app.js
a/. renderer/a/app.js renderer/app.js
a/.. renderer/app.js app.js
.. app.js app.js (already correct)

Worth noting a/. had the same bug as ., so the fix covers the sub/. form too, not just the bare case.

Base href admission. The asymmetry is closed. Both inputs now share one admitsCanonicalPathSyntax predicate, so the rule is defined once and cannot drift again. A local base href carrying NUL, a backslash, or encoded dot/separator bytes is rejected with a reason naming the base href, rather than the generic declared-path message or silent reliance on files-map confinement.

I kept one deliberate ordering: the base check runs after the external-base determination and after the root-relative early return. So https://external.test/%2e%2e/ stays external rather than rejected — an unreachable origin is the more accurate reason — and a root-relative reference is not rejected because of a base attribute it never consults. Both are asserted.

The new cases are appended to the existing JavaScriptHtmlBaseResolution.test.ts and each dot-segment case asserts the new URL() result alongside REA's, so the expectation is the standard rather than my reading of it. 7 of them fail against the pre-change file; the application suite is 313 passing.

@morluto
morluto merged commit ffbde92 into morluto:main Oct 5, 2026
18 checks passed
@rudycelekli

Copy link
Copy Markdown
Author

Reviewed the dot-segment and shared admission changes; the external-base and root-relative precedence are retained as you described. Your final formatting commit 657a602 has the same source tree as my locally verified 3fbd4c1—check:pr (1,979 passing, one declared skip), check:ci, package verification, and pack dry-run all passed on that tree. I see this is now merged, so no additional branch push is needed.

@morluto

morluto commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Thanks, @rudycelekli, for your work on “fix(javascript): respect HTML base URL components.” I appreciate your contribution to REA.

darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
* fix(javascript): respect HTML base URL components

Signed-off-by: Rudy Celekli <[email protected]>

* fix(javascript): resolve HTML base href dot segments and gate base syntax

A relative HTML reference resolves against the base URL's directory, and that
directory drops a trailing "." or ".." segment rather than stepping through
it. Only a trailing "/" was treated as a directory, so <base href=".">
resolved against the artifact root instead of the document directory, and
<base href="sub/."> resolved against the parent of "sub".

The base href is also a second untrusted path input, but rejectDeclaration
only applied its admission rules to the declared path, so an encoded-traversal
or backslash base href relied on files-map confinement to stay safe. Both
inputs now share one admitsCanonicalPathSyntax predicate, and a local base
href is rejected with a reason naming the base href rather than a generic
declared-path message. External base hrefs are still reported as external,
so an encoded path on an unreachable origin keeps the more accurate reason.

7 of the new cases fail without this change.

* style: apply Prettier to the HTML base resolution changes

---------

Signed-off-by: Rudy Celekli <[email protected]>
Co-authored-by: morluto <[email protected]>
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants