From 354ba6c2e335657a82e357ae52aee382b1815eb7 Mon Sep 17 00:00:00 2001 From: kenzuyaa Date: Tue, 26 Aug 2025 17:57:53 +0700 Subject: [PATCH] fix(core): correct filename sanitization regex and cleanup - Adjust regex to replace semicolon only with spacer - Remove colon from characters replaced by spacer, handle as removal instead - Comment out removal of extra neighbouring spacers to prevent unintended collapses - Refine unsafe characters removal pattern to avoid filename issues --- unshackle/core/utilities.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unshackle/core/utilities.py b/unshackle/core/utilities.py index 784c037..3182326 100644 --- a/unshackle/core/utilities.py +++ b/unshackle/core/utilities.py @@ -99,9 +99,9 @@ def sanitize_filename(filename: str, spacer: str = ".") -> str: # remove or replace further characters as needed filename = "".join(c for c in filename if unicodedata.category(c) != "Mn") # hidden characters filename = filename.replace("/", " & ").replace(";", " & ") # e.g. multi-episode filenames - filename = re.sub(r"[:; ]", spacer, filename) # structural chars to (spacer) - filename = re.sub(r"[\\*!?¿,'\"" "()<>|$#~]", "", filename) # not filename safe chars - filename = re.sub(rf"[{spacer}]{{2,}}", spacer, filename) # remove extra neighbouring (spacer)s + filename = re.sub(r"[;]", spacer, filename) # structural chars to (spacer) + filename = re.sub(r"[\\:*!?¿,'\"""<>|$#~]", "", filename) # not filename safe chars + # filename = re.sub(rf"[{spacer}]{{2,}}", spacer, filename) # remove extra neighbouring (spacer)s return filename