Skip to content

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

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

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

watilde added a commit that referenced this pull request Jun 29, 2026
`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>
PR-URL: #64159
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
@watilde

watilde commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

Landed in b0a4f16

@watilde watilde closed this Jun 29, 2026
@watilde watilde deleted the fix-win32-normalize-reserved-name branch June 29, 2026 09:48
@addaleax addaleax added dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. dont-land-on-v26.x PRs that should not land on the v26.x-staging branch and should not be released in v26.x. labels Jun 30, 2026
addaleax added a commit to addaleax/node that referenced this pull request Jun 30, 2026
This reverts commit b0a4f16 as it
was merged without green Jenkins CI and subsequent builds are broken.

Refs: nodejs#64159
Signed-off-by: Anna Henningsen <anna@addaleax.net>
addaleax added a commit that referenced this pull request Jun 30, 2026
This reverts commit b0a4f16 as it
was merged without green Jenkins CI and subsequent builds are broken.

Refs: #64159
Signed-off-by: Anna Henningsen <anna@addaleax.net>
PR-URL: #64216
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. dont-land-on-v26.x PRs that should not land on the v26.x-staging branch and should not be released in v26.x. 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.

5 participants