lib: handle windows reserved device names on UNC · nodejs/node@47543a7 · GitHub
Skip to content

Commit 47543a7

Browse files
committed
lib: handle windows reserved device names on UNC
We have found that UNC paths weren't covered when .join/.normalize windows reserved device names (COM1, LPT1). PR-URL: #59286 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e4ca30e commit 47543a7

3 files changed

Lines changed: 60 additions & 0 deletions

File tree

lib/path.js

Lines changed: 37 additions & 0 deletions

test/parallel/test-path-join.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ joinTests.push([
110110
[['c:.', 'file'], 'c:file'],
111111
[['c:', '/'], 'c:\\'],
112112
[['c:', 'file'], 'c:\\file'],
113+
// UNC path join tests (Windows)
114+
[['\\server\\share', 'file.txt'], '\\server\\share\\file.txt'],
115+
[['\\server\\share', 'folder', 'another.txt'], '\\server\\share\\folder\\another.txt'],
116+
[['\\server\\share', 'COM1:'], '\\server\\share\\COM1:'],
117+
[['\\server\\share', 'path', 'LPT1:'], '\\server\\share\\path\\LPT1:'],
118+
[['\\fileserver\\public\\uploads', 'CON:..\\..\\..\\private\\db.conf'],
119+
'\\fileserver\\public\\uploads\\CON:..\\..\\..\\private\\db.conf'],
120+
113121
// Path traversal in previous versions of Node.js.
114122
[['./upload', '/../C:/Windows'], '.\\C:\\Windows'],
115123
[['upload', '../', 'C:foo'], '.\\C:foo'],

test/parallel/test-path-win32-normalize-device-names.js

Lines changed: 15 additions & 0 deletions

0 commit comments

Comments
 (0)