Improve Windows reserved name check by adding to pathclass.

This commit is contained in:
voussoir 2021-07-24 12:24:24 -07:00
parent a12bc59b17
commit 13bf8e2e47
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB
2 changed files with 13 additions and 3 deletions

View file

@ -27,9 +27,10 @@ CHUNKSIZE = 4 * bytestring.KIBIBYTE
TIMEOUT = 60
TEMP_EXTENSION = '.downloadytemp'
SPECIAL_FILENAMES = [os.devnull]
if os.name == 'nt':
SPECIAL_FILENAMES.append('con')
SPECIAL_FILENAMES = pathclass.WINDOWS_RESERVED_NAMES
else:
SPECIAL_FILENAMES = [os.devnull]
SPECIAL_FILENAMES = [os.path.normcase(x) for x in SPECIAL_FILENAMES]
class DownloadyException(Exception):

View file

@ -4,7 +4,16 @@ import re
from voussoirkit import winglob
WINDOWS_BADCHARS = {'\\', '/', ':', '*', '?', '<', '>', '|', '"'}
WINDOWS_GLOBAL_BADCHARS = {'*', '?', '<', '>', '|', '"'}
WINDOWS_BASENAME_BADCHARS = {'\\', '/', ':', '*', '?', '<', '>', '|', '"'}
WINDOWS_RESERVED_NAMES = {
'AUX',
'COM1', 'COM2', 'COM3', 'COM4', 'COM5', 'COM6', 'COM7', 'COM8', 'COM9',
'CON',
'LPT1', 'LPT2', 'LPT3', 'LPT4', 'LPT5', 'LPT6', 'LPT7', 'LPT8', 'LPT9',
'NUL',
'PRN',
}
class PathclassException(Exception):
pass