From fda7841ca48ff9693788bda3888c386c21ba0df2 Mon Sep 17 00:00:00 2001 From: bushixuanqi <57338301+bushixuanqi@users.noreply.github.com> Date: Sun, 18 Jul 2021 20:52:35 +0800 Subject: [PATCH 1/6] Update HtmlFormatter.kt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化 --- app/src/main/java/io/legado/app/utils/HtmlFormatter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt index 96dbf045b..4b0660941 100644 --- a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt +++ b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt @@ -61,7 +61,7 @@ object HtmlFormatter { val url = matcher.group(1)!! val urlMatcher = AnalyzeUrl.paramPattern.matcher(url) if(urlMatcher.find()) NetworkUtils.getAbsoluteURL(redirectUrl,url.substring(0,urlMatcher.start())) + ',' + url.substring(urlMatcher.end()) - else url + else NetworkUtils.getAbsoluteURL(redirectUrl,url) }else NetworkUtils.getAbsoluteURL(redirectUrl,matcher.group(1)!!) }\">") From 78ed7240fb8ad686bbba5b053f2088584dace9d4 Mon Sep 17 00:00:00 2001 From: bushixuanqi <57338301+bushixuanqi@users.noreply.github.com> Date: Sun, 18 Jul 2021 20:58:52 +0800 Subject: [PATCH 2/6] Update HtmlFormatter.kt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 考虑更周全 --- app/src/main/java/io/legado/app/utils/HtmlFormatter.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt index 4b0660941..70bd698eb 100644 --- a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt +++ b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt @@ -32,7 +32,7 @@ object HtmlFormatter { var hasMatch = true //普通图片标签是否还未处理过 var hasMatchX = false //是否存在带参数或带数据属性的图片标签 var pos = -1 - val list = listOf("]*src *= *\"([^\"{]+\\{(?:[^{}]|\\{[^}]+\\})+\\})\"[^>]*>","]*data-[^=]*= *\"([^\"]+)\"[^>]*>","]*src *= *\"([^\"]+)\"[^>]*>") //优先匹配用户处理过所以带参数的图片标签,其次匹配带数据属性的图片标签 + val list = listOf("]*src *= *\"([^\"]+,\\s*\\{(?:[^{}]|\\{[^}]+\\})+\\})\"[^>]*>","]*data-[^=]*= *\"([^\"]+)\"[^>]*>","]*src *= *\"([^\"]+)\"[^>]*>") //优先匹配用户处理过所以带参数的图片标签,其次匹配带数据属性的图片标签 while(++pos<3){ if(pos == 2) { if(hasMatchX)break //普通图片标签只在不存在存在带参数或带数据属性的图片标签的时候匹配 @@ -60,8 +60,7 @@ object HtmlFormatter { if (pos == 0) { val url = matcher.group(1)!! val urlMatcher = AnalyzeUrl.paramPattern.matcher(url) - if(urlMatcher.find()) NetworkUtils.getAbsoluteURL(redirectUrl,url.substring(0,urlMatcher.start())) + ',' + url.substring(urlMatcher.end()) - else NetworkUtils.getAbsoluteURL(redirectUrl,url) + NetworkUtils.getAbsoluteURL(redirectUrl,url.substring(0,urlMatcher.start())) + ',' + url.substring(urlMatcher.end()) }else NetworkUtils.getAbsoluteURL(redirectUrl,matcher.group(1)!!) }\">") From 410dc45ce0b28eec737892819302c5688ea3c696 Mon Sep 17 00:00:00 2001 From: bushixuanqi <57338301+bushixuanqi@users.noreply.github.com> Date: Sun, 18 Jul 2021 21:01:04 +0800 Subject: [PATCH 3/6] Update HtmlFormatter.kt --- app/src/main/java/io/legado/app/utils/HtmlFormatter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt index 70bd698eb..bc07becc8 100644 --- a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt +++ b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt @@ -32,7 +32,7 @@ object HtmlFormatter { var hasMatch = true //普通图片标签是否还未处理过 var hasMatchX = false //是否存在带参数或带数据属性的图片标签 var pos = -1 - val list = listOf("]*src *= *\"([^\"]+,\\s*\\{(?:[^{}]|\\{[^}]+\\})+\\})\"[^>]*>","]*data-[^=]*= *\"([^\"]+)\"[^>]*>","]*src *= *\"([^\"]+)\"[^>]*>") //优先匹配用户处理过所以带参数的图片标签,其次匹配带数据属性的图片标签 + val list = listOf("]*src *= *\"([^\"]+?,\\s*\\{(?:[^{}]|\\{[^}]+\\})+\\})\"[^>]*>","]*data-[^=]*= *\"([^\"]+)\"[^>]*>","]*src *= *\"([^\"]+)\"[^>]*>") //优先匹配用户处理过所以带参数的图片标签,其次匹配带数据属性的图片标签 while(++pos<3){ if(pos == 2) { if(hasMatchX)break //普通图片标签只在不存在存在带参数或带数据属性的图片标签的时候匹配 From 58d55fcbe25db4d9bb78f61f306853eff177e247 Mon Sep 17 00:00:00 2001 From: bushixuanqi <57338301+bushixuanqi@users.noreply.github.com> Date: Sun, 18 Jul 2021 21:07:40 +0800 Subject: [PATCH 4/6] Update HtmlFormatter.kt --- app/src/main/java/io/legado/app/utils/HtmlFormatter.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt index bc07becc8..268db37f2 100644 --- a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt +++ b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt @@ -32,7 +32,7 @@ object HtmlFormatter { var hasMatch = true //普通图片标签是否还未处理过 var hasMatchX = false //是否存在带参数或带数据属性的图片标签 var pos = -1 - val list = listOf("]*src *= *\"([^\"]+?,\\s*\\{(?:[^{}]|\\{[^}]+\\})+\\})\"[^>]*>","]*data-[^=]*= *\"([^\"]+)\"[^>]*>","]*src *= *\"([^\"]+)\"[^>]*>") //优先匹配用户处理过所以带参数的图片标签,其次匹配带数据属性的图片标签 + val list = listOf("]*src *= *\"([^\"]*?,\\s*\\{(?:[^{}]|\\{[^}]+\\})+\\})\"[^>]*>","]*data-[^=]*= *\"([^\"]*)\"[^>]*>","]*src *= *\"([^\"]*)\"[^>]*>") //优先匹配用户处理过所以带参数的图片标签,其次匹配带数据属性的图片标签 while(++pos<3){ if(pos == 2) { if(hasMatchX)break //普通图片标签只在不存在存在带参数或带数据属性的图片标签的时候匹配 @@ -48,7 +48,7 @@ object HtmlFormatter { if (hasMatch) { //格式化不带参数和数据属性的普通图片标签 var appendPos0 = 0 - val matcher0 = Pattern.compile("]*src *= *\"([^\"]+)\"[^>]*>", Pattern.CASE_INSENSITIVE).matcher(strBefore) //格式化普通图片标签 + val matcher0 = Pattern.compile("]*src *= *\"([^\"]*)\"[^>]*>", Pattern.CASE_INSENSITIVE).matcher(strBefore) //格式化普通图片标签 while (matcher0.find()) { sb.append(strBefore.substring(appendPos0, matcher0.start()),"") appendPos0 = matcher0.end() @@ -82,7 +82,7 @@ object HtmlFormatter { var appendPos0 = 0 val strBefore = keepImgHtml.substring(endPos, keepImgHtml.length) val matcher0 = - Pattern.compile("]*src *= *\"([^\"]+)\"[^>]*>", Pattern.CASE_INSENSITIVE) + Pattern.compile("]*src *= *\"([^\"]*)\"[^>]*>", Pattern.CASE_INSENSITIVE) .matcher(strBefore) //格式化普通图片标签 while (matcher0.find()) { str.append(strBefore.substring(appendPos0, matcher0.start()),"") From 2c180dbd7ecf153f4fe4dc6db2aaff874c383a28 Mon Sep 17 00:00:00 2001 From: bushixuanqi <57338301+bushixuanqi@users.noreply.github.com> Date: Sun, 18 Jul 2021 21:11:38 +0800 Subject: [PATCH 5/6] Update HtmlFormatter.kt --- app/src/main/java/io/legado/app/utils/HtmlFormatter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt index 268db37f2..e16a6dd5d 100644 --- a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt +++ b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt @@ -32,7 +32,7 @@ object HtmlFormatter { var hasMatch = true //普通图片标签是否还未处理过 var hasMatchX = false //是否存在带参数或带数据属性的图片标签 var pos = -1 - val list = listOf("]*src *= *\"([^\"]*?,\\s*\\{(?:[^{}]|\\{[^}]+\\})+\\})\"[^>]*>","]*data-[^=]*= *\"([^\"]*)\"[^>]*>","]*src *= *\"([^\"]*)\"[^>]*>") //优先匹配用户处理过所以带参数的图片标签,其次匹配带数据属性的图片标签 + val list = listOf("]*src *= *\"([^\"{]*\\{(?:[^{}]|\\{[^}]+\\})+\\})\"[^>]*>","]*data-[^=]*= *\"([^\"]*)\"[^>]*>","]*src *= *\"([^\"]*)\"[^>]*>") //优先匹配用户处理过所以带参数的图片标签,其次匹配带数据属性的图片标签 while(++pos<3){ if(pos == 2) { if(hasMatchX)break //普通图片标签只在不存在存在带参数或带数据属性的图片标签的时候匹配 From e0fd6a4d3c7390c36e2591c8789016af3c43a9e4 Mon Sep 17 00:00:00 2001 From: bushixuanqi <57338301+bushixuanqi@users.noreply.github.com> Date: Sun, 18 Jul 2021 21:14:16 +0800 Subject: [PATCH 6/6] Update HtmlFormatter.kt --- app/src/main/java/io/legado/app/utils/HtmlFormatter.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt index e16a6dd5d..4ba022a73 100644 --- a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt +++ b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt @@ -60,7 +60,8 @@ object HtmlFormatter { if (pos == 0) { val url = matcher.group(1)!! val urlMatcher = AnalyzeUrl.paramPattern.matcher(url) - NetworkUtils.getAbsoluteURL(redirectUrl,url.substring(0,urlMatcher.start())) + ',' + url.substring(urlMatcher.end()) + if(urlMatcher.find()) NetworkUtils.getAbsoluteURL(redirectUrl,url.substring(0,urlMatcher.start())) + ',' + url.substring(urlMatcher.end()) + else NetworkUtils.getAbsoluteURL(redirectUrl,url) }else NetworkUtils.getAbsoluteURL(redirectUrl,matcher.group(1)!!) }\">")