From 2e517e972fde3aef007d31ecf5c679f4f4214c13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Koch-Kramer?= Date: Thu, 23 Aug 2018 22:06:35 +0200 Subject: [PATCH] Extend _PostPathFormatter to replace more chars On Windows, all forbidden characters now get replaced with similar looking unicode chars. --- instaloader/instaloader.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/instaloader/instaloader.py b/instaloader/instaloader.py index 87dab74..277ace7 100644 --- a/instaloader/instaloader.py +++ b/instaloader/instaloader.py @@ -70,7 +70,10 @@ class _PostPathFormatter(_ArbitraryItemFormatter): def vformat(self, format_string, args, kwargs): """Override :meth:`string.Formatter.vformat` for character substitution in paths for Windows, see issue #84.""" ret = super().vformat(format_string, args, kwargs) - return ret.replace(':', '\ua789') if platform.system() == 'Windows' else ret + if platform.system() == 'Windows': + ret = ret.replace(':', '\ua789').replace('<', '\ufe64').replace('>', '\ufe65').replace('\"', '\uff02') + ret = ret.replace('\\', '\uff3c').replace('|', '\uff5c').replace('?', '\ufe16').replace('*', '\uff0a') + return ret class Instaloader: