From 41fc802fb8462fb4f3ea0c79596884a6f91ec29c Mon Sep 17 00:00:00 2001 From: gedoor Date: Mon, 23 Aug 2021 11:12:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/model/webBook/BookChapterList.kt | 5 +++-- app/src/main/java/io/legado/app/model/webBook/BookContent.kt | 4 +++- app/src/main/java/io/legado/app/model/webBook/BookInfo.kt | 3 ++- app/src/main/java/io/legado/app/model/webBook/BookList.kt | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt b/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt index 9c56f3d7d..d3a244f64 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookChapterList.kt @@ -15,9 +15,10 @@ import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.async import kotlinx.coroutines.ensureActive import kotlinx.coroutines.withContext - import splitties.init.appCtx +import java.net.URLDecoder +@Suppress("BlockingMethodInNonBlockingContext") object BookChapterList { suspend fun analyzeChapterList( @@ -27,7 +28,7 @@ object BookChapterList { book: Book, redirectUrl: String ): List { - val baseUrl = strResponse.url + val baseUrl = URLDecoder.decode(strResponse.url, "utf-8") val body = strResponse.body body ?: throw Exception( appCtx.getString(R.string.error_get_web_content, baseUrl) diff --git a/app/src/main/java/io/legado/app/model/webBook/BookContent.kt b/app/src/main/java/io/legado/app/model/webBook/BookContent.kt index 84ddc575a..a34629b58 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookContent.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookContent.kt @@ -19,7 +19,9 @@ import kotlinx.coroutines.async import kotlinx.coroutines.ensureActive import kotlinx.coroutines.withContext import splitties.init.appCtx +import java.net.URLDecoder +@Suppress("BlockingMethodInNonBlockingContext") object BookContent { @Throws(Exception::class) @@ -32,7 +34,7 @@ object BookContent { redirectUrl: String, nextChapterUrl: String? = null ): String { - val baseUrl = strResponse.url + val baseUrl = URLDecoder.decode(strResponse.url, "utf-8") val body = strResponse.body body ?: throw Exception( appCtx.getString(R.string.error_get_web_content, baseUrl) diff --git a/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt b/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt index d479172a3..0149a976d 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookInfo.kt @@ -13,6 +13,7 @@ import io.legado.app.utils.StringUtils.wordCountFormat import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ensureActive import splitties.init.appCtx +import java.net.URLDecoder object BookInfo { @@ -25,7 +26,7 @@ object BookInfo { redirectUrl: String, canReName: Boolean, ) { - val baseUrl = strResponse.url + val baseUrl = URLDecoder.decode(strResponse.url, "utf-8") val body = strResponse.body body ?: throw Exception( appCtx.getString(R.string.error_get_web_content, baseUrl) diff --git a/app/src/main/java/io/legado/app/model/webBook/BookList.kt b/app/src/main/java/io/legado/app/model/webBook/BookList.kt index 50069c8cb..110e7bec5 100644 --- a/app/src/main/java/io/legado/app/model/webBook/BookList.kt +++ b/app/src/main/java/io/legado/app/model/webBook/BookList.kt @@ -16,6 +16,7 @@ import io.legado.app.utils.StringUtils.wordCountFormat import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ensureActive import splitties.init.appCtx +import java.net.URLDecoder object BookList { @@ -28,7 +29,7 @@ object BookList { variableBook: SearchBook, isSearch: Boolean = true, ): ArrayList { - val baseUrl = strResponse.url + val baseUrl = URLDecoder.decode(strResponse.url, "utf-8") val body = strResponse.body body ?: throw Exception( appCtx.getString(