Skip to content

feat(ext/node): select the stripVTControlCharacters OSC contract per runtime - #34

Merged
jackspirou merged 1 commit into
nimbus/v2.9.7from
fix/util-strip-vt-osc
Sep 24, 2026
Merged

jackspirou merged 1 commit into
nimbus/v2.9.7from
fix/util-strip-vt-osc

Conversation

@jackspirou

Copy link
Copy Markdown
Contributor

Summary

Node.js 24.21 and 26.8 changed the regex behind util.stripVTControlCharacters() (nodejs/node#64319). The new regex removes an OSC sequence up to its first terminator, whatever its payload. It also accepts : separators in SGR parameters. Earlier releases (Node.js 20, 22, 24.20, 26.7, and earlier) remove an OSC sequence only when its payload uses a restricted character set.

The fork had only the earlier regex. An embedder that targets Node.js 24.21+ or 26.8+ could not match that contract.

Change

  • Add deno_node::VtControlStripPolicy with two variants:
    • RestrictedOscPayload: Node.js 24.20, 26.7, and earlier.
    • AnyOscPayload: Node.js 24.21, 26.8, and later.
  • Add the fast op op_node_strip_vt_any_osc_payload. It reads the policy from OpState at each call, so a snapshot does not fix the policy.
  • internal/util/inspect.mjs builds both regexes and selects one per call. stripVTControlCharacters, getStringWidth, and the readline display position all use this path, as in Node.js.
  • The Deno runtime default stays RestrictedOscPayload, which matches the reported Node.js version (v26.5.1) and the vendored v26.5.1 test suite.

Tests

  • New unit test: [util] stripVTControlCharacters() keeps the restricted OSC payload contract.
  • Rust test vt_control_strip_policy_tests.
  • unit_node::util_test: pass.
  • node_compat: test-util-stripvtcontrolcharacters.js and test-readline-interface.js pass.
  • cargo test -p deno_node --lib policy: 7 passed.
  • cargo clippy -p deno_node -p deno_runtime --all-targets -D warnings, cargo fmt --check, dprint, and tools/lint.js --js: clean.

…runtime

Node.js 24.21 and 26.8 (nodejs/node#64319) changed the regex that
util.stripVTControlCharacters() uses. An OSC sequence now ends at its first
terminator whatever its payload, and SGR parameters can use `:` separators.
Earlier releases remove an OSC sequence only when its payload uses a
restricted character set.

Add VtControlStripPolicy so that an embedder can select the contract of
the Node.js release that it targets. The default stays RestrictedOscPayload,
which matches the Node.js release that Deno reports. The policy is read at
each call, so a snapshot does not fix it.
@jackspirou
jackspirou merged commit 1999c9a into nimbus/v2.9.7 Sep 24, 2026
1 check 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.

1 participant