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"]
|
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"
|
||||||
|
|||||||
@@ -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") == "a⧸b"
|
assert sanitize("a/b\\c") == "abc"
|
||||||
assert "\x01" not in sanitize("a\x01b")
|
assert "\x01" not in sanitize("a\x01b")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+4
-8
@@ -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"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user