path: fix normalization of Windows device paths missing colon#61545
path: fix normalization of Windows device paths missing colon#61545HassanFleyah wants to merge 3 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
There was a problem hiding this comment.
Pull request overview
This PR tightens path.win32.normalize() handling for Windows device paths so that reserved device names prefixed with \\.\ or \\?\ are correctly detected even when the trailing colon is missing. It aims to close an edge case where such paths could bypass existing normalization logic.
Changes:
- Refactors the UNC/device-root detection branch in
win32.normalize()to special-casefirstPart === '.' || firstPart === '?'for device roots. - Adds new logic to detect reserved device names when a
\\.\or\\?\namespace prefix is present but the path lacks a colon, usingWINDOWS_RESERVED_NAMESdirectly on the substring after the prefix.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Gentle reminder for the maintainers to authorize the pending workflows |
1 similar comment
|
Gentle reminder for the maintainers to authorize the pending workflows |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61545 +/- ##
==========================================
- Coverage 89.79% 89.78% -0.01%
==========================================
Files 672 673 +1
Lines 203809 203831 +22
Branches 39187 39174 -13
==========================================
Hits 183004 183004
- Misses 13123 13153 +30
+ Partials 7682 7674 -8
🚀 New features to boost your workflow:
|
Description
This PR fixes an inconsistency in
path.win32.normalize()where Windows reserved device names prefixed with\\.\or\\?\were not being correctly detected if they lacked a trailing colon.Current behavior:
path.normalize('\\\\.\\CON:')-> Correctly handled/sanitized.path.normalize('\\\\.\\CON')-> Returned as-is (Inconsistent).This change ensures that
\\.\CONand\\?\CONare treated consistently with other device paths by strictly checking against the reserved names list when the namespace prefix is present but the colon is missing.Context
This addresses an edge case where valid Windows device paths bypass normalization logic due to the missing colon expectation.
Testing
I have verified this fix locally.