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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user