Skip to content

Commit 961efd7

Browse files
cliffhallclaude
andcommitted
fix(filesystem): match any character in a device name's extension
The device-name pattern's extension used `.`, which does not match U+2028/U+2029, so NUL.<U+2028>txt slipped past it. The pattern now uses the s flag, with regression cases. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent a2f4694 commit 961efd7

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎src/filesystem/__tests__/windows-reserved-names.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ describe("namesWindowsDevice on win32", () => {
5353
"C:\\work\\NUL.txt",
5454
"C:\\work\\com1.tar.gz",
5555
"C:\\work\\CON .txt",
56+
// `.` must match any character in the extension, line separators included.
57+
"C:\\work\\NUL.\u2028txt",
58+
"C:\\work\\NUL.\u2029txt",
5659
"C:\\work\\aux\\file.txt",
5760
"\\\\?\\C:\\work\\NUL",
5861
"\\\\.\\NUL",

‎src/filesystem/path-validation.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const WINDOWS_UNC_ROOT =
4444
/^(?:\\\\[?.]\\UNC\\|\\\\(?![?.]\\))[^\\/]+[\\/][^\\/]+/i;
4545

4646
const WINDOWS_DEVICE_NAME =
47-
/^(?:CON|PRN|AUX|NUL|COM[1-9¹²³]|LPT[1-9¹²³]) *(?:\..*)?$/i;
47+
/^(?:CON|PRN|AUX|NUL|COM[1-9¹²³]|LPT[1-9¹²³]) *(?:\..*)?$/is;
4848

4949
function windowsNameComponents(normalizedPath: string): string[] {
5050
return normalizedPath

0 commit comments

Comments
 (0)