From fb3281b6476a21d4b918c98359d8885d72c62c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Wilczy=C5=84ski?= Date: Tue, 29 Sep 2020 03:35:54 +0900 Subject: [PATCH] lib/fs: Add COM0 and LPT0 to invalid Windows file names (ref #7008) (#7013) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit COM0 and LPT0 are not listed in the official Microsoft's documentation at https://docs.microsoft.com/windows/win32/fileio/naming-a-file, but in reality are also invalid in Windows Explorer. Signed-off-by: Tomasz WilczyƄski --- lib/fs/util.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/fs/util.go b/lib/fs/util.go index 2503fe270..ad530d668 100644 --- a/lib/fs/util.go +++ b/lib/fs/util.go @@ -53,14 +53,15 @@ var ( 31, }) windowsDisallowedNames = []string{"CON", "PRN", "AUX", "NUL", - "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", - "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9", + "COM0", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", + "LPT0", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9", } ) func WindowsInvalidFilename(name string) error { // None of the path components should end in space or period, or be a - // reserved name. + // reserved name. COM0 and LPT0 are missing from the Microsoft docs, + // but Windows Explorer treats them as invalid too. // (https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file) for _, part := range strings.Split(name, `\`) { if len(part) == 0 {