Manhuagui: Fix single quote parsing (#7471)

* manhuagui: convert single quote before unpack

* manhuagui: bump extension version to 21
This commit is contained in:
heddxh 2025-02-03 12:44:33 +08:00 committed by Draff
parent 0658c1926c
commit c4c6fe69f4
No known key found for this signature in database
GPG Key ID: E8A89F3211677653
2 changed files with 7 additions and 5 deletions

View File

@ -1,7 +1,7 @@
ext { ext {
extName = 'ManHuaGui' extName = 'ManHuaGui'
extClass = '.Manhuagui' extClass = '.Manhuagui'
extVersionCode = 20 extVersionCode = 21
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -380,6 +380,8 @@ class Manhuagui(
private val packedContentRegex = Regex("""['"]([0-9A-Za-z+/=]+)['"]\[['"].*?['"]]\(['"].*?['"]\)""") private val packedContentRegex = Regex("""['"]([0-9A-Za-z+/=]+)['"]\[['"].*?['"]]\(['"].*?['"]\)""")
private val singleQuoteRegex = Regex("""\\'""")
override fun pageListParse(document: Document): List<Page> { override fun pageListParse(document: Document): List<Page> {
// R18 warning element (#erroraudit_show) is remove by web page javascript, so here the warning element // R18 warning element (#erroraudit_show) is remove by web page javascript, so here the warning element
// will always exist if this manga is R18 limited whether R18 verification cookies has been sent or not. // will always exist if this manga is R18 limited whether R18 verification cookies has been sent or not.
@ -393,13 +395,13 @@ class Manhuagui(
// Make the packed content normal again so :lib:unpacker can do its job // Make the packed content normal again so :lib:unpacker can do its job
it.replace(packedContentRegex) { match -> it.replace(packedContentRegex) { match ->
val lzs = match.groupValues[1] val lzs = match.groupValues[1]
val decoded = LZString.decompressFromBase64(lzs).replace("'", "\\'") val decoded = LZString.decompressFromBase64(lzs)
"'$decoded'.split('|')" "'$decoded'.split('|')"
} }
} }
val imgDecode = Unpacker.unpack(imgCode) // Convert single quote to dash before passing to unpack, since unpack will replace it
// with double quote, which may make json parse fail.
val imgDecode = Unpacker.unpack(singleQuoteRegex.replace(imgCode, "-"))
val imgJsonStr = blockCcArgRegex.find(imgDecode)!!.groupValues[0] val imgJsonStr = blockCcArgRegex.find(imgDecode)!!.groupValues[0]
val imageJson: Comic = json.decodeFromString(imgJsonStr) val imageJson: Comic = json.decodeFromString(imgJsonStr)