Copilot/handle extended path on windows#1
Merged
Conversation
Strip the \\?\ extended-length path prefix from Windows paths in fs.realpathSync and fs.realpath before the path walking logic. The \\?\ prefix is a Win32 API mechanism to bypass MAX_PATH limits. When a user passes a path like \\?\C:\path\to\file.js, Node.js should handle it transparently by converting to the standard C:\path\to\file.js form for internal processing. The \\?\ prefix is re-added as needed via path.toNamespacedPath() before actual system calls. Handles two forms of extended paths: - \\?\C:\path -> C:\path (extended drive path) - \\?\UNC\server\share -> \\server\share (extended UNC path) Fixes: nodejs#62446 Agent-Logs-Url: https://github.com/jazelly/node/sessions/77c338e9-ef46-46f1-8800-b6ad9a74ab36 Co-authored-by: jazelly <28685065+jazelly@users.noreply.github.com>
Agent-Logs-Url: https://github.com/jazelly/node/sessions/77c338e9-ef46-46f1-8800-b6ad9a74ab36 Co-authored-by: jazelly <28685065+jazelly@users.noreply.github.com>
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.
Note
Medium Risk
Touches core path canonicalization logic in
fs.realpath*on Windows, which could impact edge-case path handling and caching behavior despite being narrowly scoped and covered by a new regression test.Overview
fs.realpathSync()andfs.realpath()now normalize Windows extended-length paths by stripping the\\?\prefix (including\\?\C:\...and\\?\UNC\...) before the internal path-walking/symlink-resolution logic runs, and re-strip afterpath.resolve()when symlink targets are recomputed.Adds a Windows-only regression test covering extended-length file paths, drive roots, and subdirectory paths to ensure
realpathreturns standard (non-namespaced) paths.Written by Cursor Bugbot for commit 4a66705. This will update automatically on new commits. Configure here.