From 91106d98e7b65be878916f49d8680c74f713c7ba Mon Sep 17 00:00:00 2001 From: RafaelGSS Date: Thu, 17 Jul 2025 15:25:06 -0300 Subject: [PATCH] lib: handle superscript variants on windows device MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows recognizes the 8-bit [ISO/IEC 8859-1](https://en.wikipedia.org/wiki/ISO/IEC_8859-1) superscript digits ¹, ², and ³ as digits and treats them as valid parts of COM# and LPT# device names, making them reserved in every directory. Signed-off-by: RafaelGSS --- lib/path.js | 2 ++ test/parallel/test-path-win32-normalize-device-names.js | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/lib/path.js b/lib/path.js index 70b0f67e93bf1e..bee827c06e9973 100644 --- a/lib/path.js +++ b/lib/path.js @@ -73,6 +73,8 @@ const WINDOWS_RESERVED_NAMES = [ 'CON', 'PRN', 'AUX', 'NUL', 'COM1', 'COM2', 'COM3', 'COM4', 'COM5', 'COM6', 'COM7', 'COM8', 'COM9', 'LPT1', 'LPT2', 'LPT3', 'LPT4', 'LPT5', 'LPT6', 'LPT7', 'LPT8', 'LPT9', + 'COM\xb9', 'COM\xb2', 'COM\xb3', + 'LPT\xb9', 'LPT\xb2', 'LPT\xb3', ]; function isWindowsReservedName(path, colonIndex) { diff --git a/test/parallel/test-path-win32-normalize-device-names.js b/test/parallel/test-path-win32-normalize-device-names.js index 927bc5cec8a2e5..2c6dcf142a2674 100644 --- a/test/parallel/test-path-win32-normalize-device-names.js +++ b/test/parallel/test-path-win32-normalize-device-names.js @@ -45,10 +45,18 @@ const normalizeDeviceNameTests = [ { input: 'COM1:', expected: '.\\COM1:.' }, { input: 'COM9:', expected: '.\\COM9:.' }, + { input: 'COM¹:', expected: '.\\COM¹:.' }, + { input: 'COM²:', expected: '.\\COM²:.' }, + { input: 'COM³:', expected: '.\\COM³:.' }, { input: 'COM1:.\\..\\..\\foo', expected: '.\\COM1:..\\..\\foo' }, + { input: 'COM¹:.\\..\\..\\foo', expected: '.\\COM¹:..\\..\\foo' }, { input: 'LPT1:', expected: '.\\LPT1:.' }, + { input: 'LPT¹:', expected: '.\\LPT¹:.' }, + { input: 'LPT²:', expected: '.\\LPT²:.' }, + { input: 'LPT³:', expected: '.\\LPT³:.' }, { input: 'LPT9:', expected: '.\\LPT9:.' }, { input: 'LPT1:.\\..\\..\\foo', expected: '.\\LPT1:..\\..\\foo' }, + { input: 'LPT¹:.\\..\\..\\foo', expected: '.\\LPT¹:..\\..\\foo' }, { input: 'LpT5:/another/path', expected: '.\\LpT5:another\\path' }, { input: 'C:\\foo', expected: 'C:\\foo' },