From 223b72430676e4850651f2a3947d697f1538ea6d Mon Sep 17 00:00:00 2001 From: bushixuanqi <2208877960@qq.com> Date: Sun, 18 Jul 2021 00:54:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=93=BE=E6=8E=A5=E5=88=86?= =?UTF-8?q?=E5=89=B2=E8=A7=84=E5=88=99=EF=BC=8C=E9=81=BF=E5=85=8D=E9=99=84?= =?UTF-8?q?=E5=8A=A0=E5=8F=82=E6=95=B0=E4=B8=AD=E5=AD=98=E5=9C=A8=20,{=20?= =?UTF-8?q?=E6=97=B6=E5=AF=BC=E8=87=B4=E8=A7=84=E5=88=99=E5=88=87=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复这种页数列表写法中,js部分内含 < 或 > 会切割错误的问题 格式化图片和匹配图片规则不在使用同一个正则,加快图片处理速度。 优化一下不需要循环执行却被循环执行的操作 --- .../app/model/analyzeRule/AnalyzeRule.kt | 3 -- .../app/model/analyzeRule/AnalyzeUrl.kt | 10 ++--- .../read/page/provider/ChapterProvider.kt | 37 +++++++++---------- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index 11f967773..3753738eb 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -394,10 +394,7 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions { 1 }else 0 var tmp: String - - val jsMatcher = JS_PATTERN.matcher(ruleStr) - while (jsMatcher.find()){ if (jsMatcher.start() > start) { tmp = ruleStr.substring(start, jsMatcher.start()).trim { it <= ' ' } diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index 9dc1fcc72..90b4be570 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -142,18 +142,14 @@ class AnalyzeUrl( */ private fun initUrl() { //replaceKeyPageJs已经替换掉额外内容,此处url是基础形式,可以直接切首个‘,’之前字符串。 - var pos = ruleUrl.indexOf(',') - urlHasQuery = ruleUrl.substringBefore(',') - url = NetworkUtils.getAbsoluteURL(baseUrl,urlHasQuery ) - NetworkUtils.getBaseUrl(url)?.let { baseUrl = it } - if(pos != -1 ) { - GSON.fromJsonObject(ruleUrl.substring(pos + 1).trim{ it < '!'})?.let { option -> + if(urlHasQuery.length != ruleUrl.length ) { + GSON.fromJsonObject(ruleUrl.substring(urlHasQuery.length + 1).trim{ it < '!'})?.let { option -> option.method?.let { if (it.equals("POST", true)) method = RequestMethod.POST @@ -191,7 +187,7 @@ class AnalyzeUrl( when (method) { RequestMethod.GET -> { if (!useWebView) { - pos = url.indexOf('?') + val pos = url.indexOf('?') if(pos != -1) { analyzeFields(url.substring(pos + 1)) url = url.substring(0,pos) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt index c58c38b9f..c3bbf8b6e 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt @@ -111,27 +111,26 @@ object ChapterProvider { ) } } else if (book.getImageStyle() != Book.imgStyleText) { - var contentX = content.replace(AppPattern.imgPattern.toRegex(), "\n\$0\n").split("\n") - val start = contentX.first() == "\n" - val end = contentX.last() == "\n" - if(start || end )contentX = contentX.subList(if(start) 1 else 0,if(end) contentX.size-1 else contentX.size ) - contentX.forEach { text -> - if (!text.startsWith(" + if(text.isNotBlank()){ + if (!text.startsWith("