From df842939f6edd572a51259044589c296898085e7 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 17 Mar 2021 14:57:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= 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 | 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 d4c32b68c..fc5d75c51 100644 --- a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt +++ b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt @@ -7,7 +7,7 @@ object HtmlFormatter { private val wrapHtmlRegex = "]*>".toRegex() private val notImgHtmlRegex = "])[^<>]*>".toRegex() private val otherHtmlRegex = "])[^<>]*>".toRegex() - private val imgPattern = Pattern.compile("(]*src=\"([^\"]+)\"[^>]*(>)") + private val imgPattern = Pattern.compile("]*src=.*?\"(.*?(?:,\\{.*\\})?)\".*?>") fun format(html: String?): String { html ?: return "" @@ -32,8 +32,8 @@ object HtmlFormatter { val sb = StringBuffer() val matcher = imgPattern.matcher(html) while (matcher.find()) { - val url = NetworkUtils.getAbsoluteURL(redirectUrl, matcher.group(2)!!) - matcher.appendReplacement(sb, "${matcher.group(1)} src=\"$url\"${matcher.group(3)}") + val url = NetworkUtils.getAbsoluteURL(redirectUrl, matcher.group(1)!!) + matcher.appendReplacement(sb, "") } matcher.appendTail(sb) return sb.replace(wrapHtmlRegex, "\n")