This commit is contained in:
Kovid Goyal 2021-03-17 09:10:42 +05:30
parent 8b4d27a75b
commit 73a8699e0a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -20,6 +20,7 @@ from polyglot.builtins import unicode_type, zip, getcwd, as_unicode
def sanitize_file_name(x):
ans = re.sub(r'\s+', ' ', re.sub(r'[?&=;#]', '_', ascii_filename(x))).strip().rstrip('.')
ans = re.sub(r'\%2[fF]', '_', ans)
ans, ext = ans.rpartition('.')[::2]
return (ans.strip() + '.' + ext.strip()).rstrip('.')