Skip to content

path: canonicalize Windows namespaced paths#62639

Closed
jazelly wants to merge 1 commit into
nodejs:mainfrom
jazelly:fix-62446
Closed

path: canonicalize Windows namespaced paths#62639
jazelly wants to merge 1 commit into
nodejs:mainfrom
jazelly:fix-62446

Conversation

@jazelly

@jazelly jazelly commented Apr 8, 2026

Copy link
Copy Markdown
Member

Canonicalize valid Windows namespaced drive and UNC filesystem paths by stripping the prefix in these 2 kinds

\\?\C:\foo
\\?\UNC\server\share\foo

This is safe for ToNamespacedPath() because it resolves to the regular drive or UNC spelling before adding the namespace prefix back for Windows filesystem calls.

Fixes: #62446

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Apr 8, 2026
@jazelly jazelly added fs Issues and PRs related to the fs subsystem / file system. path Issues and PRs related to the path subsystem. labels Apr 8, 2026
@StefanStojanovic StefanStojanovic added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 9, 2026
@jazelly jazelly force-pushed the fix-62446 branch 2 times, most recently from 8a63ce2 to 9c279df Compare April 29, 2026 22:48
@johncrim

johncrim commented Jun 9, 2026

Copy link
Copy Markdown

Related:
#60435
#61165

Another PR which provides a simpler fix for those issues. Ideally this PR should handle the toRealPath() exception too.

@jazelly jazelly marked this pull request as ready for review June 9, 2026 06:07
@jazelly jazelly added request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Jun 9, 2026
@jazelly jazelly force-pushed the fix-62446 branch 2 times, most recently from 6468284 to d0dc6a0 Compare June 9, 2026 06:17
@jazelly

jazelly commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

@johncrim I think that's two different things, although very close, to fix. This PR aims to fix the extended path on windows.

@jazelly jazelly added request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Jun 9, 2026
@jazelly jazelly changed the title path: handle extended-length windows entry paths path: canonicalize Windows namespaced paths Jun 9, 2026
Canonicalize Windows namespaced paths at internal filesystem identity
boundaries. Valid namespaced drive and UNC paths identify the same
filesystem objects as their non-namespaced spelling, so internal cache,
permission, and module lookups should compare the canonical identity
rather than the user-provided spelling.

Only the two known filesystem-equivalent namespace forms are rewritten:
\\?\C:\... and \\?\UNC\server\share\.... Other namespaced
forms are preserved because they may refer to device or drive-relative
semantics that are not equivalent to ordinary drive or UNC paths.

Signed-off-by: jazelly <xzha4350@gmail.com>
@jazelly

jazelly commented Jun 9, 2026

Copy link
Copy Markdown
Member Author

After second thoughts and understanding to other mentioned issues, I think we should take care of them at the js layer to be safer. Closing this

@jazelly jazelly closed this Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. path Issues and PRs related to the path subsystem. request-ci Add this label to start a Jenkins CI on a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node cannot handle extended windows paths

4 participants