From 179a1f1159bdfc744434fdd7df54ca137d2e2f39 Mon Sep 17 00:00:00 2001 From: Alessandro Jean Date: Sat, 21 Aug 2021 23:41:12 -0300 Subject: [PATCH] Fix JSON parsing exception not handled in Madara. (#8721) --- .../java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt | 7 ++++--- .../eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt index 6361937d5..df7dd9131 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/Madara.kt @@ -596,11 +596,12 @@ abstract class Madara( val wpMangaData = document.select("script#wp-manga-js-extra").firstOrNull() ?.data() ?: return null - val wpManga = wpMangaData + val wpMangaInfo = wpMangaData .substringAfter("var manga = ") .substringBeforeLast(";") - .let { json.parseToJsonElement(it) } - .jsonObject + + val wpManga = runCatching { json.parseToJsonElement(wpMangaInfo).jsonObject } + .getOrNull() ?: return null if (wpManga["enable_manga_view"]?.jsonPrimitive?.content == "1") { val formBuilder = FormBody.Builder() diff --git a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt index fc91caa1c..4eda58802 100644 --- a/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt +++ b/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/madara/MadaraGenerator.kt @@ -10,7 +10,7 @@ class MadaraGenerator : ThemeSourceGenerator { override val themeClass = "Madara" - override val baseVersionCode: Int = 10 + override val baseVersionCode: Int = 11 override val sources = listOf( MultiLang("Leviatan Scans", "https://leviatanscans.com", listOf("en", "es"), className = "LeviatanScansFactory", overrideVersionCode = 6),