Make the file name safe function less restrictive

This commit is contained in:
Veronica Berglyd Olsen committed 2024-06-11 21:38:50 +02:00
1 parent 6d54902a08
commit 556caea308
2 files changed
+34 -8

No files matched your search

+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: