pull/1128/head^2
gedoor 3 years ago
parent ef46ae8022
commit 9cac73f303
  1. 49
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt

@ -445,35 +445,38 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions {
var tmp: String var tmp: String
val evalMatcher = evalPattern.matcher(rule) val evalMatcher = evalPattern.matcher(rule)
while (evalMatcher.find()) { if (evalMatcher.find()) {
if (evalMatcher.start() > start) { if (mode != Mode.Js && mode != Mode.Regex
tmp = rule.substring(start, evalMatcher.start())
if (mode != Mode.Js && mode != Mode.Regex
&& start == 0 && !tmp.contains("##")
) {
mode = Mode.Regex
}
splitRegex(tmp)
} else if (mode != Mode.Js && mode != Mode.Regex
&& evalMatcher.start() == 0 && evalMatcher.start() == 0
) { ) {
mode = Mode.Regex mode = Mode.Regex
} }
tmp = evalMatcher.group() do {
when { if (evalMatcher.start() > start) {
tmp.startsWith("@get:", true) -> { tmp = rule.substring(start, evalMatcher.start())
ruleType.add(getRuleType) if (mode != Mode.Js && mode != Mode.Regex
ruleParam.add(tmp.substring(6, tmp.lastIndex)) && start == 0 && !tmp.contains("##")
} ) {
tmp.startsWith("{{") -> { mode = Mode.Regex
ruleType.add(jsRuleType) }
ruleParam.add(tmp.substring(2, tmp.length - 2))
}
else -> {
splitRegex(tmp) splitRegex(tmp)
} }
} tmp = evalMatcher.group()
start = evalMatcher.end() when {
tmp.startsWith("@get:", true) -> {
ruleType.add(getRuleType)
ruleParam.add(tmp.substring(6, tmp.lastIndex))
}
tmp.startsWith("{{") -> {
ruleType.add(jsRuleType)
ruleParam.add(tmp.substring(2, tmp.length - 2))
}
else -> {
splitRegex(tmp)
}
}
start = evalMatcher.end()
} while (evalMatcher.find())
} }
if (rule.length > start) { if (rule.length > start) {
tmp = rule.substring(start) tmp = rule.substring(start)

Loading…
Cancel
Save