修复htmlFormatter错误

pull/1063/head
gedoor 4 years ago
parent 3ca9015de9
commit 952581db05
  1. 9
      app/src/main/java/io/legado/app/utils/HtmlFormatter.kt

@ -22,8 +22,9 @@ object HtmlFormatter {
fun formatKeepImg(html: String?, redirectUrl: URL?): String {
html ?: return ""
val keepImgHtml = formatKeepImg(html)
val sb = StringBuffer()
val matcher = AppPattern.imgPattern.matcher(formatKeepImg(html))
val matcher = AppPattern.imgPattern.matcher(keepImgHtml)
var appendPos = 0
while (matcher.find()) {
val urlArray = matcher.group(1)!!.split(AnalyzeUrl.splitUrlRegex)
@ -31,12 +32,12 @@ object HtmlFormatter {
if (urlArray.size > 1) {
url = "$url,${urlArray[1]}"
}
sb.append(html.substring(appendPos, matcher.start()))
sb.append(keepImgHtml.substring(appendPos, matcher.start()))
sb.append("<img src=\"$url\" >")
appendPos = matcher.end()
}
if (appendPos < html.length) {
sb.append(html.substring(appendPos, html.length))
if (appendPos < keepImgHtml.length) {
sb.append(keepImgHtml.substring(appendPos, keepImgHtml.length))
}
return sb.toString()
}

Loading…
Cancel
Save