path: fix win32 normalize false-positive on reserved names#64159
Open
watilde wants to merge 1 commit into
Open
path: fix win32 normalize false-positive on reserved names#64159watilde wants to merge 1 commit into
watilde wants to merge 1 commit into
Conversation
`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>
Collaborator
|
Review requested:
|
jasnell
approved these changes
Jun 27, 2026
Collaborator
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.
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 andisWindowsReservedName()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.\CONxinstead ofCONx.Guard the check with
colonIndex !== -1, matching the other reserved name call sites which are already guarded bycolonIndex > 0.