Fix possible crash: only throw IOException in intecept (#12835)
This commit is contained in:
parent
5efea62807
commit
58652bbf76
@ -5,7 +5,7 @@ ext {
|
||||
extName = 'Koushoku'
|
||||
pkgNameSuffix = 'en.koushoku'
|
||||
extClass = '.Koushoku'
|
||||
extVersionCode = 11
|
||||
extVersionCode = 12
|
||||
isNsfw = true
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,6 @@ class Koushoku : ParsedHttpSource() {
|
||||
|
||||
override fun headersBuilder(): Headers.Builder = super.headersBuilder()
|
||||
.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36")
|
||||
.add("Origin", baseUrl)
|
||||
.add("Referer", "$baseUrl/")
|
||||
|
||||
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/?page=$page", headers)
|
||||
@ -147,8 +146,6 @@ class Koushoku : ParsedHttpSource() {
|
||||
status = SManga.COMPLETED
|
||||
}
|
||||
|
||||
override fun chapterListRequest(manga: SManga) = GET("$baseUrl${manga.url}", headers)
|
||||
|
||||
override fun chapterListParse(response: Response): List<SChapter> {
|
||||
val document = response.asJsoup()
|
||||
|
||||
@ -167,7 +164,7 @@ class Koushoku : ParsedHttpSource() {
|
||||
|
||||
override fun chapterListSelector() = throw UnsupportedOperationException("Not used")
|
||||
|
||||
override fun pageListRequest(chapter: SChapter) = GET("$baseUrl${chapter.url}/1")
|
||||
override fun pageListRequest(chapter: SChapter) = GET("$baseUrl${chapter.url}/1", headers)
|
||||
|
||||
override fun pageListParse(document: Document): List<Page> {
|
||||
val totalPages = document.selectFirst(".total").text().toInt()
|
||||
|
@ -4,7 +4,6 @@ import android.annotation.SuppressLint
|
||||
import android.app.Application
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import okhttp3.Interceptor
|
||||
@ -21,11 +20,14 @@ class KoushokuWebViewInterceptor : Interceptor {
|
||||
val request = chain.request()
|
||||
val response = chain.proceed(request)
|
||||
|
||||
val responseBody = response.peekBody(1 * 1024 * 1024).toString()
|
||||
val document = Jsoup.parse(responseBody)
|
||||
if (document.selectFirst("h1")?.text()?.contains(Regex("banned$")) == true) {
|
||||
throw Exception("You have been banned. Check WebView for details.")
|
||||
} else if (response.headers("Content-Type").any { it.contains("text/html") }) {
|
||||
if (response.headers("Content-Type").any { it.contains("text/html") }) {
|
||||
val responseBody = response.peekBody(1 * 1024 * 1024).toString()
|
||||
val document = Jsoup.parse(responseBody)
|
||||
|
||||
if (document.selectFirst("h1")?.text()?.contains(Regex("banned$")) == true) {
|
||||
throw IOException("You have been banned. Check WebView for details.")
|
||||
}
|
||||
|
||||
try {
|
||||
proceedWithWebView(response)
|
||||
} catch (e: Exception) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user