From b2aefb0b8c54db2545c59ee9d805412d6ab3cd51 Mon Sep 17 00:00:00 2001 From: bushixuanqi <57338301+bushixuanqi@users.noreply.github.com> Date: Thu, 8 Jul 2021 20:41:40 +0800 Subject: [PATCH] Update RuleAnalyzer.kt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 平衡组区分内嵌{JSONPATH}和非内嵌JSONPATH --- .../java/io/legado/app/model/analyzeRule/RuleAnalyzer.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/RuleAnalyzer.kt b/app/src/main/java/io/legado/app/model/analyzeRule/RuleAnalyzer.kt index 6a5c674ec..55942b001 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/RuleAnalyzer.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/RuleAnalyzer.kt @@ -10,6 +10,7 @@ class RuleAnalyzer(data: String, code:Boolean = false) { private var start = 0 //每次处理字段的开始 private var startX = 0 //规则的开始 + private var innerStr: Boolean = false //true表示以平衡组的起点为规则起始,false表示不这样 private var step:Int = 0 //分割字符的长度 val chompBalanced = if(code) ::chompCodeBalanced else ::chompRuleBalanced //设置平衡组函数,json或JavaScript时设置成chompCodeBalanced,否则为chompRuleBalanced @@ -229,7 +230,7 @@ class RuleAnalyzer(data: String, code:Boolean = false) { } while (depth > 0 || otherDepth > 0) //拉出一个平衡字串 return if(depth > 0 || otherDepth > 0) false else { - startX = this.pos //内嵌规则起始 + if(innerStr)startX = this.pos //内嵌规则起始 this.pos = pos //同步位置 true } @@ -428,6 +429,8 @@ class RuleAnalyzer(data: String, code:Boolean = false) { val start0 = pos //规则匹配前起点 + innerStr = true //设置平衡组以平衡组起点为规则起始点 + val st = StringBuilder() while (!isEmpty && consumeTo(inner)) { //拉取成功返回true,ruleAnalyzes里的字符序列索引变量pos后移相应位置,否则返回false,且isEmpty为true