Skip to content

path: fix win32 normalize false-positive on reserved names#64159

Open
watilde wants to merge 1 commit into
nodejs:mainfrom
watilde:fix-win32-normalize-reserved-name
Open

path: fix win32 normalize false-positive on reserved names#64159
watilde wants to merge 1 commit into
nodejs:mainfrom
watilde:fix-win32-normalize-reserved-name

Conversation

@watilde

@watilde watilde commented Jun 27, 2026

Copy link
Copy Markdown
Member

path.win32.normalize() checked for Windows reserved device names (CON, NUL, PRN, LPT1, etc.) without first ensuring the path actually contained a colon. When no colon was present, indexOf(':') returned -1 and isWindowsReservedName() sliced off the last character instead of slicing up to a colon, so any filename equal to a reserved name plus one trailing character was wrongly treated as a device and prefixed with .\ — e.g. normalize('CONx') returned .\CONx instead of CONx.

Guard the check with colonIndex !== -1, matching the other reserved name call sites which are already guarded by colonIndex > 0.

`path.win32.normalize()` checked for Windows reserved device names
(CON, NUL, PRN, LPT1, etc.) without first ensuring the path actually
contained a colon. When no colon was present, `indexOf(':')` returned
-1 and `isWindowsReservedName()` sliced off the last character instead
of slicing up to a colon, so any filename equal to a reserved name plus
one trailing character was wrongly treated as a device and prefixed with
`.\` — e.g. `normalize('CONx')` returned `.\CONx` instead of `CONx`.

Guard the check with `colonIndex !== -1`, matching the other reserved
name call sites which are already guarded by `colonIndex > 0`.

Signed-off-by: Daijiro Wachi <daijiro.wachi@gmail.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/path

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. path Issues and PRs related to the path subsystem. labels Jun 27, 2026
@watilde watilde added the request-ci Add this label to start a Jenkins CI on a PR. label Jun 27, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jun 27, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@gurgunday gurgunday left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. path Issues and PRs related to the path subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants