|
|
@ -48,6 +48,7 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions { |
|
|
|
fun setContent(content: Any?, baseUrl: String? = null): AnalyzeRule { |
|
|
|
fun setContent(content: Any?, baseUrl: String? = null): AnalyzeRule { |
|
|
|
if (content == null) throw AssertionError("内容不可空(Content cannot be null)") |
|
|
|
if (content == null) throw AssertionError("内容不可空(Content cannot be null)") |
|
|
|
this.content = content |
|
|
|
this.content = content |
|
|
|
|
|
|
|
isJSON = content.toString().isJson() |
|
|
|
setBaseUrl(baseUrl) |
|
|
|
setBaseUrl(baseUrl) |
|
|
|
objectChangedXP = true |
|
|
|
objectChangedXP = true |
|
|
|
objectChangedJS = true |
|
|
|
objectChangedJS = true |
|
|
@ -64,8 +65,7 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions { |
|
|
|
|
|
|
|
|
|
|
|
fun setRedirectUrl(url: String): URL? { |
|
|
|
fun setRedirectUrl(url: String): URL? { |
|
|
|
kotlin.runCatching { |
|
|
|
kotlin.runCatching { |
|
|
|
val pos = url.indexOf(',') |
|
|
|
redirectUrl = URL(url.substringBefore(",{")) |
|
|
|
redirectUrl = URL( if(pos == -1) url else url.substring(0,pos)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return redirectUrl |
|
|
|
return redirectUrl |
|
|
|
} |
|
|
|
} |
|
|
@ -378,12 +378,12 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions { |
|
|
|
mMode = Mode.Json |
|
|
|
mMode = Mode.Json |
|
|
|
ruleStr0.substring(6) |
|
|
|
ruleStr0.substring(6) |
|
|
|
} |
|
|
|
} |
|
|
|
ruleStr0.startsWith(":") -> { //:与伪类选择器冲突,改成?更合理 |
|
|
|
ruleStr0.startsWith(":") -> { //:与伪类选择器冲突,建议改成?更合理 |
|
|
|
mMode = Mode.Regex |
|
|
|
mMode = Mode.Regex |
|
|
|
isRegex = true |
|
|
|
isRegex = true |
|
|
|
ruleStr0.substring(1) |
|
|
|
ruleStr0.substring(1) |
|
|
|
} |
|
|
|
} |
|
|
|
( ruleStr0[1] == '.' || ruleStr0[1] == '[') && ruleStr0[0] == '$' || content.toString().isJson() -> { |
|
|
|
( ruleStr0[1] == '.' || ruleStr0[1] == '[') && ruleStr0[0] == '$' || isJSON -> { |
|
|
|
mMode = Mode.Json |
|
|
|
mMode = Mode.Json |
|
|
|
ruleStr0 |
|
|
|
ruleStr0 |
|
|
|
} |
|
|
|
} |
|
|
@ -596,15 +596,14 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun isRule(ruleStr: String): Boolean { |
|
|
|
private fun isRule(ruleStr: String): Boolean { |
|
|
|
return when { |
|
|
|
return ruleStr.startsWith('@') //js首个字符不可能是@,除非是装饰器,所以@开头规定为规则 |
|
|
|
ruleStr.startsWith("$.") -> true |
|
|
|
|| ruleStr.startsWith('$') //js首个字符不可能是$,因为并未注入$变量,且$1之类的东西已被替换,不会影响此处判断 |
|
|
|
ruleStr.startsWith("@Json:", true) -> true |
|
|
|
|| ruleStr.startsWith("//") |
|
|
|
ruleStr.startsWith("//") -> true |
|
|
|
|| ruleStr.startsWith("class")//js首个字符串不可能是class,因为并未注入相关字符串开头的变量 |
|
|
|
ruleStr.startsWith("@XPath:", true) -> true |
|
|
|
|| ruleStr.startsWith("id")//js首个字符串不可能是id,因为并未注入相关字符串开头的变量 |
|
|
|
ruleStr.startsWith("@CSS:", true) -> true |
|
|
|
|| ruleStr.startsWith("tag")//js首个字符串不可能是tag,因为并未注入相关字符串开头的变量 |
|
|
|
ruleStr.startsWith("@@") -> true |
|
|
|
|| ruleStr.startsWith("text")//js首个字符串不可能是text,因为并未注入相关字符串开头的变量 |
|
|
|
else -> false |
|
|
|
|| ruleStr.startsWith("children")//js首个字符串不可能是children,因为并未注入相关字符串开头的变量 |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|