Repository navigation
fix(javascript): respect HTML base URL components - #589
Conversation
Signed-off-by: Rudy Celekli <[email protected]>
…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.
|
Pushed
Worth noting Base href admission. The asymmetry is closed. Both inputs now share one I kept one deliberate ordering: the base check runs after the external-base determination and after the root-relative early return. So The new cases are appended to the existing |
|
Reviewed the dot-segment and shared admission changes; the external-base and root-relative precedence are retained as you described. Your final formatting commit |
|
Thanks, @rudycelekli, for your work on “fix(javascript): respect HTML base URL components.” I appreciate your contribution to REA. |
* 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]>
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
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:prnpm run check:cinpm run verify:packagenpm pack --dry-runDevelopment 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.