Deny invalid files on Windows

This commit is contained in:
shortcutme 2019-11-07 02:47:19 +01:00
parent f172751df3
commit d569d9488a
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 23 additions and 3 deletions

View file

@ -599,6 +599,12 @@ class ContentManager(object):
return False
elif len(relative_path) > 255:
return False
elif relative_path[0] in (".", "/"): # Starts with
return False
elif relative_path[-1] in (".", " "): # Ends with
return False
elif re.match(r".*(^|/)(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9]|CONOUT\$|CONIN\$)(\.|/|$)", relative_path, re.IGNORECASE): # Protected on Windows
return False
else:
return re.match(r"^[^\x00-\x1F\"*:<>?\\|]+$", relative_path)