Skip to content

path: strip extended-length path prefix in C++ PathResolve and JS win32.resolve#2

Merged
jazelly merged 1 commit intofix-62446from
copilot/fix-cpp-layer-issue
Apr 1, 2026
Merged

path: strip extended-length path prefix in C++ PathResolve and JS win32.resolve#2
jazelly merged 1 commit intofix-62446from
copilot/fix-cpp-layer-issue

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 1, 2026

  • Analyze the culprit PR path,win: fix bug in resolve and normalize nodejs/node#55623 and understand the C++ layer issue
  • Add StripExtendedPathPrefix helper to src/path.cc that strips \\?\C:\...C:\... and \\?\UNC\...\\... (leaving device paths unchanged)
  • Call the helper in PathResolve for each input path
  • Add corresponding stripping logic in lib/path.js win32.resolve to keep JS/C++ in sync
  • Revert the heavy JS changes in lib/fs.js (remove stripExtendedPathPrefix and all call sites)
  • Remove test/parallel/test-fs-realpath-extended-windows-path.js (replaced by C++ tests)
  • Add C++ test cases in test/cctest/test_path.cc for extended-length path resolution
  • Add JS test cases in test/parallel/test-path-resolve.js
  • Run code review and address feedback
  • Run CodeQL security check

…2.resolve (JS)

Move the fix for Windows extended-length path prefix handling from
lib/fs.js to the C++ PathResolve function (src/path.cc) and the JS
path.resolve function (lib/path.js).

The \\?\ prefix is a Win32 API mechanism for bypassing MAX_PATH limits.
When path.resolve encounters paths like \\?\C:\foo or \\?\UNC\server\share,
it should strip the prefix and resolve the underlying standard path.
Device paths like \\?\PHYSICALDRIVE0 are left unchanged.

This fix addresses the root cause in the path resolution layer rather
than working around it in fs.realpathSync/realpath.

Agent-Logs-Url: https://github.com/jazelly/node/sessions/b73cebf2-9b87-42a3-a50e-c5da1b454971

Co-authored-by: jazelly <28685065+jazelly@users.noreply.github.com>
@jazelly jazelly marked this pull request as ready for review April 1, 2026 04:20
@jazelly jazelly merged commit 118ce75 into fix-62446 Apr 1, 2026
20 checks 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.

2 participants