mirror of
https://github.com/Garmelon/PFERD.git
synced 2025-07-12 06:02:31 +02:00
Sanitize individual path parts
This commit is contained in:
@ -21,7 +21,8 @@ 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)))
|
sanitized_parts = [re.sub(r'[<>:"/|?]', "_", x) for x in list(path.parts)]
|
||||||
|
return PurePath(*sanitized_parts)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user