From a0ae9aee2730a75558d525bdb1d36f89f9da27ae Mon Sep 17 00:00:00 2001 From: I-Al-Istannen Date: Wed, 11 Nov 2020 09:36:20 +0100 Subject: [PATCH] Sanitize individual path parts --- sync_url.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sync_url.py b/sync_url.py index 998584f..2b8bc56 100755 --- a/sync_url.py +++ b/sync_url.py @@ -21,7 +21,8 @@ from PFERD.utils import to_path def sanitize_path(path: PurePath) -> Optional[PurePath]: # Escape windows illegal path characters 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