Fix JSON parsing exception not handled in Madara. (#8721)

This commit is contained in:
Alessandro Jean 2021-08-21 23:41:12 -03:00 committed by GitHub
parent 8a52a4db06
commit 179a1f1159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -596,11 +596,12 @@ abstract class Madara(
val wpMangaData = document.select("script#wp-manga-js-extra").firstOrNull() val wpMangaData = document.select("script#wp-manga-js-extra").firstOrNull()
?.data() ?: return null ?.data() ?: return null
val wpManga = wpMangaData val wpMangaInfo = wpMangaData
.substringAfter("var manga = ") .substringAfter("var manga = ")
.substringBeforeLast(";") .substringBeforeLast(";")
.let { json.parseToJsonElement(it) }
.jsonObject val wpManga = runCatching { json.parseToJsonElement(wpMangaInfo).jsonObject }
.getOrNull() ?: return null
if (wpManga["enable_manga_view"]?.jsonPrimitive?.content == "1") { if (wpManga["enable_manga_view"]?.jsonPrimitive?.content == "1") {
val formBuilder = FormBody.Builder() val formBuilder = FormBody.Builder()

View File

@ -10,7 +10,7 @@ class MadaraGenerator : ThemeSourceGenerator {
override val themeClass = "Madara" override val themeClass = "Madara"
override val baseVersionCode: Int = 10 override val baseVersionCode: Int = 11
override val sources = listOf( override val sources = listOf(
MultiLang("Leviatan Scans", "https://leviatanscans.com", listOf("en", "es"), className = "LeviatanScansFactory", overrideVersionCode = 6), MultiLang("Leviatan Scans", "https://leviatanscans.com", listOf("en", "es"), className = "LeviatanScansFactory", overrideVersionCode = 6),