1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-26 18:10:30 +00:00
This commit is contained in:
Ozzie Isaacs 2022-05-04 19:22:18 +02:00
parent 1bcb714fac
commit 056ecf0d90

View File

@ -241,8 +241,7 @@ def get_valid_filename(value, replace_whitespace=True, chars=128):
# pipe has to be replaced with comma # pipe has to be replaced with comma
value = re.sub(r'[|]+', u',', value, flags=re.U) value = re.sub(r'[|]+', u',', value, flags=re.U)
filename_encoding_for_length = 'utf-16' if sys.platform == "win32" or sys.platform == "darwin" else 'utf-8' value = value.encode('utf-8')[:chars].decode('utf-8', errors='ignore').strip()
value = value.encode(filename_encoding_for_length)[:chars].decode('utf-8', errors='ignore').strip()
if not value: if not value:
raise ValueError("Filename cannot be empty") raise ValueError("Filename cannot be empty")