Repository navigation
feat(ext/node): select the stripVTControlCharacters OSC contract per runtime - #34
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
deno_node::VtControlStripPolicywith two variants:RestrictedOscPayload: Node.js 24.20, 26.7, and earlier.AnyOscPayload: Node.js 24.21, 26.8, and later.op_node_strip_vt_any_osc_payload. It reads the policy fromOpStateat each call, so a snapshot does not fix the policy.internal/util/inspect.mjsbuilds both regexes and selects one per call.stripVTControlCharacters,getStringWidth, and the readline display position all use this path, as in Node.js.RestrictedOscPayload, which matches the reported Node.js version (v26.5.1) and the vendored v26.5.1 test suite.Tests
[util] stripVTControlCharacters() keeps the restricted OSC payload contract.vt_control_strip_policy_tests.unit_node::util_test: pass.node_compat:test-util-stripvtcontrolcharacters.jsandtest-readline-interface.jspass.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, andtools/lint.js --js: clean.