Make the file name safe function less restrictive

This commit is contained in:
Veronica Berglyd Olsen
2024-06-11 21:38:50 +02:00
parent 6d54902a08
commit 556caea308
2 changed files with 34 additions and 8 deletions
+2 -3
View File
@@ -523,12 +523,11 @@ def readTextFile(path: str | Path) -> str:
def makeFileNameSafe(text: str) -> str:
"""Return a filename safe string.
"""Return a filename-safe string.
See: https://unicode.org/reports/tr15/#Norm_Forms
"""
text = unicodedata.normalize("NFKC", text).strip()
allowed = (" ", ".", "-", "_")
return "".join(c for c in text if c.isalnum() or c in allowed)
return "".join(c for c in text if c.isprintable() and c not in r'\/:*?"<>|')
def getFileSize(path: Path) -> int: