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] 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()),"")