From 99cb6ec8fee46f239348d14babd13037d965007c Mon Sep 17 00:00:00 2001 From: Celeter Date: Fri, 28 Feb 2020 23:56:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9UA=EF=BC=8C=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=97=A7=E4=B9=A6=E6=BA=90=E8=BD=AC=E6=8D=A2=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/constant/AppConst.kt | 2 +- .../java/io/legado/app/help/storage/OldRule.kt | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/constant/AppConst.kt b/app/src/main/java/io/legado/app/constant/AppConst.kt index 3a5b42efe..96cc7567f 100644 --- a/app/src/main/java/io/legado/app/constant/AppConst.kt +++ b/app/src/main/java/io/legado/app/constant/AppConst.kt @@ -22,7 +22,7 @@ object AppConst { const val UA_NAME = "User-Agent" val userAgent: String by lazy { - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36" + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36" } val SCRIPT_ENGINE: ScriptEngine by lazy { diff --git a/app/src/main/java/io/legado/app/help/storage/OldRule.kt b/app/src/main/java/io/legado/app/help/storage/OldRule.kt index c8036e559..7696bb383 100644 --- a/app/src/main/java/io/legado/app/help/storage/OldRule.kt +++ b/app/src/main/java/io/legado/app/help/storage/OldRule.kt @@ -100,15 +100,22 @@ object OldRule { if (oldRule.isNullOrBlank()) return null var newRule = oldRule var reverse = false + var allinone = false if (oldRule.startsWith("-")) { reverse = true newRule = oldRule.substring(1) } + if (newRule.startsWith("+")) { + allinone = true + newRule = newRule.substring(1) + } if (!newRule.startsWith("@CSS:", true) && !newRule.startsWith("@XPath:", true) && !newRule.startsWith("//") && !newRule.startsWith("##") && - !newRule.startsWith(":") + !newRule.startsWith(":") && + !newRule.contains("@js:",true) && + !newRule.contains("",true) ) { if (newRule.contains("#") && !newRule.contains("##")) { newRule = oldRule.replace("#", "##") @@ -134,8 +141,11 @@ object OldRule { newRule = newRule.replace("&", "&&") } } + if (allinone) { + newRule = "+" + newRule + } if (reverse) { - newRule += "-" + newRule = "-" + newRule } return newRule } @@ -145,7 +155,7 @@ object OldRule { if (!oldUrls.contains("\n") && !oldUrls.contains("&&")) return toNewUrl(oldUrls) - val urls = oldUrls.split("(&&|\n)+".toRegex()) + val urls = oldUrls.split("(&&|\r?\n)+".toRegex()) return urls.map { toNewUrl(it)?.replace("\n\\s*".toRegex(), "") }.joinToString("\n")