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  ")