Skip to content

Define a safe inline script content contract - #215

Merged
trueadm merged 3 commits into
mainfrom
codex/script-innerhtml-contract
Jul 21, 2026
Merged

trueadm merged 3 commits into
mainfrom
codex/script-innerhtml-contract

Conversation

@trueadm

@trueadm trueadm commented Jul 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • define raw <script>...</script> bodies as static script data, with braces kept as literal JavaScript/JSON source
  • document dangerouslySetInnerHTML={{ __html: ... }} as the supported dynamic whole-script path
  • preserve authored static script characters in direct templates and value-position descriptors
  • keep client updates, buffered/streaming SSR, and hydration aligned while neutralizing case-insensitive opening/closing script tokens
  • add a patch changeset and public-boundary regressions for executable scripts, application/json, and speculation rules

Addresses JS-01 from #211 only.

Root cause

The current @tsrx/core parser exposes a complete script body as verbatim raw text rather than expression AST nodes. Octane therefore cannot safely recover an authored JSX expression from braces, which are also valid JavaScript syntax. In addition, static script data was passing through generic HTML text escaping even though HTML entities are not decoded in the script-data state.

This change makes that parser boundary an explicit language contract instead of attempting ambiguous regex recovery. Dynamic values use the existing attribute expression AST retained by dangerouslySetInnerHTML; client writes use textContent, while server output applies whole-script token neutralization. Hydration compares against the browser-normalized server spelling, including CRLF/CR normalization.

Validation

  • focused regression matrix: 12 files, 420 assertions across client dev/prod and server paths
  • ./node_modules/.bin/tsgo --noEmit -p packages/octane/tsconfig.json
  • pnpm --config.minimum-release-age=0 format:check
  • pnpm --config.minimum-release-age=0 changeset:check
  • git diff --check

No dependency or lockfile changes.


Note

Medium Risk
Touches compiler SSR/client emission and hydration comparison for script elements—security-sensitive HTML boundary behavior—but changes are narrowly scoped with extensive regression tests and fail-closed validation.

Overview
Defines how <script> bodies work in Octane: authored content is verbatim script data (braces stay literal JS/JSON, not TSRX interpolation), with dangerouslySetInnerHTML as the supported path for dynamic whole-script values. README documents static vs dynamic usage and the security boundary (token neutralization, not JS sanitization).

The compiler threads @tsrx/core’s element.content through normalization, SSR/client templates, and de-opt createElement paths: static bodies skip generic HTML escaping, only neutralize case-insensitive </script / <script tokens, and apply script-data line/NUL normalization so client and SSR spellings match. dangerouslySetInnerHTML vs children validation treats non-empty static script bodies (including whitespace-only) as real content.

Server joins primitive-only descriptor children before escaping so breakout tokens cannot straddle fragments. Client hydration for script dangerouslySetInnerHTML compares against the same escaped + normalized spelling the browser parsed from SSR, avoiding false mismatches while updates still use textContent.

Adds a patch changeset, loadCompiledFixtureSource for client/server compile tests, fixtures, and a broad regression suite (executable, JSON, speculation rules, static boundaries, hydration).

Reviewed by Cursor Bugbot for commit 2610780. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
octane-website Ready Ready Preview, Comment Jul 21, 2026 12:42pm
octane-website-mcp Ready Ready Preview, Comment Jul 21, 2026 12:42pm

Request Review

@trueadm
trueadm marked this pull request as ready for review July 21, 2026 11:54
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 21, 2026 11:54 Inactive
Comment thread packages/octane/src/runtime.ts Resolved
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 21, 2026 12:05 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 21, 2026 12:06 Inactive

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 164e218. Configure here.

Comment thread packages/octane/src/runtime.server.ts Resolved
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp July 21, 2026 12:41 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website July 21, 2026 12:42 Inactive
@trueadm
trueadm merged commit b92d76e into main Jul 21, 2026
22 checks passed
@trueadm
trueadm deleted the codex/script-innerhtml-contract branch July 21, 2026 12:56
mrdiyorbek-juraev added a commit to mrdiyorbek-juraev/octane that referenced this pull request Jul 21, 2026
Brings in 5 upstream commits: the safe inline-script content contract
(octanejs#215), the tanstack.com shell port (octanejs#214), the TSRX directive arm output
docs (octanejs#213), the inline hook-memo tier (octanejs#208), and the website menu /
scroll-spy work (octanejs#209). Upstream added three bindings
(tanstack-router-ssr-query, tanstack-hotkeys, tanstack-pacer), taking the
table to 39.

Six conflicts, all resolved as unions so neither side lost content:

- website/src/content/bindings.json — @octanejs/cmdk listed alongside
  upstream's three new bindings; the "UI and interaction" description
  keeps command menus and gains keyboard shortcuts and event pacing.
- website/public/llms.txt — same union in prose form.
- docs/bindings-status.md, docs/packages.md, docs/binding-parity-gaps.md
  and the evals user-apps-v1 manifest are generated, so they were taken
  from upstream and regenerated (39 bindings, 48 publishable packages,
  0 parity pins, 19 eval tasks).

packages/cmdk is byte-identical to its pre-merge state; upstream's
compiler changes do not perturb it. Verified: 32/32 cmdk and cmdk-ssr
tests including both differential parity checks against [email protected],
tsrx-tsc and tsgo clean, prettier clean, and all five freshness gates
current.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

This branch was previously deployed

2 inactive deployments
Preview – octane-website — 26107805 Deployed Jul 21, 2026 by vercel[bot]
Preview – octane-website-mcp — 26107805 Deployed Jul 21, 2026 by vercel[bot]
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.

1 participant