fix(core): ui questionmark

This commit is contained in:
Steppenstreuner
2026-08-28 18:55:40 +02:00
parent 6b2c92e367
commit 24e3e9658e
3 changed files with 8 additions and 12 deletions
+1 -1
View File
@@ -160,7 +160,7 @@ def test_audio_tags_written_on_import(client):
}]}) }]})
assert resp.json()["results"][0]["ok"] assert resp.json()["results"][0]["ok"]
dest = root / "Ulf Blanck" / "Die drei ??? Kids Folge 085" # "?" becomes fullwidth dest = root / "Ulf Blanck" / "Die drei ??? Kids Folge 085"
files = sorted(dest.iterdir()) files = sorted(dest.iterdir())
tags = ID3(files[0]) tags = ID3(files[0])
assert str(tags["TALB"]) == "Die drei ??? Kids Folge 085" assert str(tags["TALB"]) == "Die drei ??? Kids Folge 085"
+3 -3
View File
@@ -9,9 +9,9 @@ def req(**kw):
return SimpleNamespace(**base) return SimpleNamespace(**base)
def test_sanitize_replaces_forbidden_chars(): def test_sanitize_keeps_special_chars_but_strips_separators():
assert sanitize("Die drei ???") == "Die drei ???" assert sanitize("Die drei ???") == "Die drei ???"
assert sanitize("a/b") == "ab" assert sanitize("a/b\\c") == "abc"
assert "\x01" not in sanitize("a\x01b") assert "\x01" not in sanitize("a\x01b")
+4 -8
View File
@@ -1,16 +1,12 @@
import re import re
# characters not allowed in (Windows/SMB-safe) file names are replaced with # only path separators and control chars are truly forbidden on Linux; keep
# fullwidth lookalikes so names like "Die drei ???" stay readable # everything else literal so names like "Die drei ???" survive as-is
_REPLACEMENTS = str.maketrans({ _FORBIDDEN = re.compile(r"[/\\\x00-\x1f]")
"<": "", ">": "", ":": "", '"': "", "/": "",
"\\": "", "|": "", "?": "", "*": "",
})
_CONTROL = re.compile(r"[\x00-\x1f]")
def sanitize(part: str, max_len: int = 120) -> str: def sanitize(part: str, max_len: int = 120) -> str:
part = _CONTROL.sub("", part.translate(_REPLACEMENTS)).strip(" .") part = _FORBIDDEN.sub("", part).strip(" .")
part = re.sub(r"\s+", " ", part) part = re.sub(r"\s+", " ", part)
return part[:max_len].strip(" .") or "Unknown" return part[:max_len].strip(" .") or "Unknown"