From a7c7ed3b77d5d0a0aa3c28935fa3940d3c1c7d8b Mon Sep 17 00:00:00 2001 From: mobi2002 <48650614+mobi2002@users.noreply.github.com> Date: Mon, 20 Feb 2023 23:15:11 +0500 Subject: [PATCH] cubari: prevent `NullPointerException` when key is 084 and chapter_number is 84 (#15418) * cubari: fix prevent `NullPointerException` when chapters.key is 084 and chapter.chapter_number is 84 * bump version * simplify by using mapKeys --- src/all/cubari/build.gradle | 2 +- .../src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/all/cubari/build.gradle b/src/all/cubari/build.gradle index 335aefa9f..d9c6d33b8 100644 --- a/src/all/cubari/build.gradle +++ b/src/all/cubari/build.gradle @@ -6,7 +6,7 @@ ext { extName = 'Cubari' pkgNameSuffix = "all.cubari" extClass = '.CubariFactory' - extVersionCode = 17 + extVersionCode = 18 } apply from: "$rootDir/common.gradle" diff --git a/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt b/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt index 0b9d51d06..5c1564dbc 100644 --- a/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt +++ b/src/all/cubari/src/eu/kanade/tachiyomi/extension/all/cubari/Cubari.kt @@ -183,7 +183,10 @@ open class Cubari(override val lang: String) : HttpSource() { val groupMap = groups.entries.associateBy({ it.value.jsonPrimitive.content.ifEmpty { "default" } }, { it.key }) val chapterScanlator = chapter.scanlator ?: "default" // workaround for "" as group causing NullPointerException (#13772) - val chapters = jsonObj["chapters"]!!.jsonObject + // prevent NullPointerException when chapters.key is 084 and chapter.chapter_number is 84 + val chapters = jsonObj["chapters"]!!.jsonObject.mapKeys { + it.key.replace(Regex("^0+(?!$)"), "") + } val pages = if (chapters[chapter.chapter_number.toString()] != null) { chapters[chapter.chapter_number.toString()]!!