Skip to content

fix(node:path): preserve unpaired UTF-16 surrogates - #163

Merged
steipete merged 1 commit into
mainfrom
fix/path-preserve-surrogates
Oct 14, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/path-preserve-surrogates

Conversation

@steipete

@steipete steipete commented Oct 14, 2026 •

Copy link
Copy Markdown

What does this PR do?

Preserve unpaired UTF-16 code units throughout node:path on both posix and win32. Previously, converting inputs to UTF-8 replaced lone surrogates with U+FFFD. This also fixes suffix comparisons that remove one code unit from a surrogate pair.

Adapts the implementation and tests from oven-sh#34596 by @robobun to the current borrowed-string API. Wide path arguments use the existing UTF-16 algorithms; mixed-width arguments widen Latin-1. format() retains field strings across user getters. The scratch pool keeps the same byte capacities with two-byte alignment. resolve() preserves its existing replaceable process.cwd and WTF-8 handling and now encodes argument strings through the same lossless bridge.

How did you verify your code works?

Node 24.21.0 passes all 80 checks in a standalone path-family matrix; stock Bun 1.4.3 passes 42. The new Bun regression tests cover lone high/low surrogates, valid pairs, mixed-width arguments, format getters that force GC, and a basename suffix splitting a pair.

On Linux x64, a release build passes bun run build:release test test/js/node/path: 170 passed, 3 existing platform skips, 0 failed across 19 files. The new regression filter reports 1 pass, 6 failures on the unpatched build. The standalone family matrix passes 80/80 on the patched binary.

OpenClaw’s extensions/codex/src/app-server/sandbox-exec-server/fs-policy.test.ts passes 12/12 on Node 24 and the patched Bun binary; the unpatched fork reports 11 passed, 1 failed, specifically the Unicode code-point case. Tests used private home/state/temp directories.

Independent Codex and Claude reviews are scoped-clean at P2 against the fork base. BUN_CODEGEN_DIR selected the release-generated sources for bun run rust:check-all: 2 targets passed, 0 failed, 10 skipped because their standard libraries were not installed on the proof host.

The upstream proposal remains open; this fork adaptation does not open a competing upstream PR.

CI on this head passed native Linux x64 and macOS arm64 build/test jobs, formatting, JavaScript/source lints, clippy, mordant, Miri, lol-html tests, and Socket Security. The only failed check is the existing claude-find-issues automation: run 38530109349 fails environment validation before analysis because no Anthropic API, OAuth, or federation credential is configured. It produced no code finding and was not rerun.

Adapt oven-sh#34596 to borrowed string views and retain the existing
lossless process.cwd handling in resolve. Cover both path variants and
suffix comparisons that split a valid surrogate pair.

Co-authored-by: robobun <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T07:47:56.407143Z 852102f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete
steipete merged commit 247dd62 into main Oct 14, 2026
13 of 14 checks passed
@steipete
steipete deleted the fix/path-preserve-surrogates branch October 14, 2026 08:10
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