Fix: Crash on HTML response in EventRepository and others

- Fixed: Value <! DOCTYPE cannot be converted to JSONArray in EventRepository
- Fixed: Added HTML validation in UpdateManager and DeviceRegistry
- Fixed: Improved HTTP error handling in StreamUrlResolver
- Improved: Error messages in PlayerActivity
- Bumped version to 9.4.3
This commit is contained in:
renato97
2026-01-26 21:44:07 +01:00
parent 05625ffe50
commit bac564eb4f
8 changed files with 343 additions and 26 deletions

View File

@@ -172,6 +172,16 @@ public class UpdateManager {
}
private UpdateInfo parseRelease(String responseBody) throws JSONException, IOException {
if (responseBody == null || responseBody.trim().isEmpty()) {
throw new JSONException("La respuesta está vacía");
}
// Validar que no sea HTML antes de parsear
String trimmed = responseBody.trim();
if (trimmed.startsWith("<!") || trimmed.startsWith("<html")) {
throw new JSONException("Se recibió HTML en lugar de JSON");
}
JSONObject releaseJson = new JSONObject(responseBody);
String tagName = releaseJson.optString("tag_name", "");
String versionName = deriveVersionName(tagName, releaseJson.optString("name"));
@@ -244,6 +254,11 @@ public class UpdateManager {
}
String json = response.body().string();
if (!TextUtils.isEmpty(json)) {
// Validar que no sea HTML antes de parsear
String trimmed = json.trim();
if (trimmed.startsWith("<!") || trimmed.startsWith("<html")) {
continue;
}
return new JSONObject(json);
}
}