From a49e5f3235f1965caf40735f4618b7bed4d55b6d Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 17 Mar 2021 19:55:10 +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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 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 fc5d75c51..bffdac06d 100644 --- a/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt +++ b/app/src/main/java/io/legado/app/utils/HtmlFormatter.kt @@ -31,11 +31,16 @@ object HtmlFormatter { html ?: return "" val sb = StringBuffer() val matcher = imgPattern.matcher(html) + var appendPos = 0 while (matcher.find()) { val url = NetworkUtils.getAbsoluteURL(redirectUrl, matcher.group(1)!!) - matcher.appendReplacement(sb, "") + sb.append(html.substring(appendPos, matcher.start())) + sb.append("") + appendPos = matcher.end() + } + if (appendPos < html.length) { + sb.append(html.substring(appendPos, html.length)) } - matcher.appendTail(sb) return sb.replace(wrapHtmlRegex, "\n") .replace(notImgHtmlRegex, "") .replace("\\s*\\n+\\s*".toRegex(), "\n  ")