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'
|
extName = 'Koushoku'
|
||||||
pkgNameSuffix = 'en.koushoku'
|
pkgNameSuffix = 'en.koushoku'
|
||||||
extClass = '.Koushoku'
|
extClass = '.Koushoku'
|
||||||
extVersionCode = 11
|
extVersionCode = 12
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,6 @@ class Koushoku : ParsedHttpSource() {
|
|||||||
|
|
||||||
override fun headersBuilder(): Headers.Builder = super.headersBuilder()
|
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")
|
.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/")
|
.add("Referer", "$baseUrl/")
|
||||||
|
|
||||||
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/?page=$page", headers)
|
override fun latestUpdatesRequest(page: Int) = GET("$baseUrl/?page=$page", headers)
|
||||||
@ -147,8 +146,6 @@ class Koushoku : ParsedHttpSource() {
|
|||||||
status = SManga.COMPLETED
|
status = SManga.COMPLETED
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun chapterListRequest(manga: SManga) = GET("$baseUrl${manga.url}", headers)
|
|
||||||
|
|
||||||
override fun chapterListParse(response: Response): List<SChapter> {
|
override fun chapterListParse(response: Response): List<SChapter> {
|
||||||
val document = response.asJsoup()
|
val document = response.asJsoup()
|
||||||
|
|
||||||
@ -167,7 +164,7 @@ class Koushoku : ParsedHttpSource() {
|
|||||||
|
|
||||||
override fun chapterListSelector() = throw UnsupportedOperationException("Not used")
|
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> {
|
override fun pageListParse(document: Document): List<Page> {
|
||||||
val totalPages = document.selectFirst(".total").text().toInt()
|
val totalPages = document.selectFirst(".total").text().toInt()
|
||||||
|
@ -4,7 +4,6 @@ import android.annotation.SuppressLint
|
|||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.util.Log
|
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import android.webkit.WebViewClient
|
import android.webkit.WebViewClient
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
@ -21,11 +20,14 @@ class KoushokuWebViewInterceptor : Interceptor {
|
|||||||
val request = chain.request()
|
val request = chain.request()
|
||||||
val response = chain.proceed(request)
|
val response = chain.proceed(request)
|
||||||
|
|
||||||
|
if (response.headers("Content-Type").any { it.contains("text/html") }) {
|
||||||
val responseBody = response.peekBody(1 * 1024 * 1024).toString()
|
val responseBody = response.peekBody(1 * 1024 * 1024).toString()
|
||||||
val document = Jsoup.parse(responseBody)
|
val document = Jsoup.parse(responseBody)
|
||||||
|
|
||||||
if (document.selectFirst("h1")?.text()?.contains(Regex("banned$")) == true) {
|
if (document.selectFirst("h1")?.text()?.contains(Regex("banned$")) == true) {
|
||||||
throw Exception("You have been banned. Check WebView for details.")
|
throw IOException("You have been banned. Check WebView for details.")
|
||||||
} else if (response.headers("Content-Type").any { it.contains("text/html") }) {
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
proceedWithWebView(response)
|
proceedWithWebView(response)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user