From 93de115dc013db79b7cba4aec1f14328df114086 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 15 Mar 2023 19:48:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=88=E6=94=B9=E5=9B=9E=E6=9D=A5=20?= =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E8=BF=99=E6=A0=B7=E7=9A=84url=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=AD=A3=E7=A1=AE=E8=AF=86=E5=88=AB=E4=BA=86=20http:/?= =?UTF-8?q?/android.jjwxc.net/androidapi/search=3Fkeyword=3D{{key}}&type?= =?UTF-8?q?=3D1&page=3D{{page}}&searchType=3D7&sortMode=3DDESC=20@js:java.?= =?UTF-8?q?put('key',key);java.put('page',page);result?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/model/analyzeRule/AnalyzeUrl.kt | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) 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 b8b283136d98..c6c332e97183 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 @@ -113,27 +113,29 @@ class AnalyzeUrl( */ private fun analyzeJs() { var start = 0 + var tmp: String val jsMatcher = JS_PATTERN.matcher(ruleUrl) - var result = ruleUrl + var hasRule = true while (jsMatcher.find()) { - if (jsMatcher.start() > start && start > 0) { - ruleUrl.substring(start, jsMatcher.start()).trim().let { - if (it.isNotEmpty()) { - result = it.replace("@result", result) - } + if (jsMatcher.start() > start) { + tmp = + ruleUrl.substring(start, jsMatcher.start()).trim { it <= ' ' } + if (tmp.isNotEmpty()) { + ruleUrl = tmp.replace("@result", ruleUrl) } } - result = evalJS(jsMatcher.group(2) ?: jsMatcher.group(1), result) as String + ruleUrl = evalJS(jsMatcher.group(2) ?: jsMatcher.group(1), ruleUrl) as String start = jsMatcher.end() + if (jsMatcher.group(0)!!.startsWith("@js:", true)) { + hasRule = false + } } - if (ruleUrl.length > start) { - ruleUrl.substring(start).trim().let { - if (it.isNotEmpty()) { - result = it.replace("@result", result) - } + if (ruleUrl.length > start && hasRule) { + tmp = ruleUrl.substring(start).trim { it <= ' ' } + if (tmp.isNotEmpty()) { + ruleUrl = tmp.replace("@result", ruleUrl) } } - ruleUrl = result } /**