fix(core): ui questionmark
This commit is contained in:
@@ -160,7 +160,7 @@ def test_audio_tags_written_on_import(client):
|
||||
}]})
|
||||
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())
|
||||
tags = ID3(files[0])
|
||||
assert str(tags["TALB"]) == "Die drei ??? Kids Folge 085"
|
||||
|
||||
@@ -9,9 +9,9 @@ def req(**kw):
|
||||
return SimpleNamespace(**base)
|
||||
|
||||
|
||||
def test_sanitize_replaces_forbidden_chars():
|
||||
assert sanitize("Die drei ???") == "Die drei ???"
|
||||
assert sanitize("a/b") == "a⧸b"
|
||||
def test_sanitize_keeps_special_chars_but_strips_separators():
|
||||
assert sanitize("Die drei ???") == "Die drei ???"
|
||||
assert sanitize("a/b\\c") == "abc"
|
||||
assert "\x01" not in sanitize("a\x01b")
|
||||
|
||||
|
||||
|
||||
+4
-8
@@ -1,16 +1,12 @@
|
||||
import re
|
||||
|
||||
# characters not allowed in (Windows/SMB-safe) file names are replaced with
|
||||
# fullwidth lookalikes so names like "Die drei ???" stay readable
|
||||
_REPLACEMENTS = str.maketrans({
|
||||
"<": "<", ">": ">", ":": ":", '"': """, "/": "⧸",
|
||||
"\\": "⧹", "|": "|", "?": "?", "*": "*",
|
||||
})
|
||||
_CONTROL = re.compile(r"[\x00-\x1f]")
|
||||
# only path separators and control chars are truly forbidden on Linux; keep
|
||||
# everything else literal so names like "Die drei ???" survive as-is
|
||||
_FORBIDDEN = re.compile(r"[/\\\x00-\x1f]")
|
||||
|
||||
|
||||
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)
|
||||
return part[:max_len].strip(" .") or "Unknown"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user