mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 07:56:52 +08:00
Handle invalid UTF-8 with replacement decoding
This commit is contained in:
@@ -131,7 +131,7 @@ def _read_json(path: Path) -> Optional[dict[str, Any]]:
|
||||
if not path.exists():
|
||||
return None
|
||||
try:
|
||||
data = json.loads(path.read_text(encoding="utf-8"))
|
||||
data = json.loads(path.read_text(encoding="utf-8", errors="replace"))
|
||||
except (OSError, json.JSONDecodeError):
|
||||
return None
|
||||
return data if isinstance(data, dict) else None
|
||||
@@ -249,7 +249,7 @@ def _backend_health_payload(port: int, timeout: float = BACKEND_HEALTH_TIMEOUT)
|
||||
with urlopen(request, timeout=timeout) as response:
|
||||
if response.status != 200:
|
||||
return None
|
||||
raw = response.read().decode("utf-8", errors="ignore")
|
||||
raw = response.read().decode("utf-8", errors="replace")
|
||||
except (HTTPError, URLError):
|
||||
return None
|
||||
except OSError:
|
||||
@@ -672,7 +672,7 @@ def _check_frontend_assets(runner: DoctorRunnerProtocol) -> None:
|
||||
|
||||
version = ""
|
||||
try:
|
||||
version = (frontend_dir / "version.txt").read_text(encoding="utf-8").strip()
|
||||
version = (frontend_dir / "version.txt").read_text(encoding="utf-8", errors="replace").strip()
|
||||
except OSError:
|
||||
version = "unknown"
|
||||
runner.add(
|
||||
|
||||
Reference in New Issue
Block a user