Use "_" as a replacement for illegal characters

This commit is contained in:
I-Al-Istannen 2020-11-10 20:49:14 +01:00
parent f2aba970fd
commit 4ac51048c1

View File

@ -15,14 +15,13 @@ from PFERD import Pferd
from PFERD.cookie_jar import CookieJar from PFERD.cookie_jar import CookieJar
from PFERD.ilias import (IliasCrawler, IliasElementType, from PFERD.ilias import (IliasCrawler, IliasElementType,
KitShibbolethAuthenticator) KitShibbolethAuthenticator)
from PFERD.transform import re_rename
from PFERD.utils import to_path from PFERD.utils import to_path
def sanitize_path(path: PurePath) -> Optional[PurePath]: def sanitize_path(path: PurePath) -> Optional[PurePath]:
# Escape windows illegal path characters # Escape windows illegal path characters
if os.name == 'nt': if os.name == 'nt':
return PurePath(re.sub(r'[<>:"/\\|?]', "", str(path))) return PurePath(re.sub(r'[<>:"/\\|?]', "_", str(path)))
return path return path