优化链接分割规则,避免 ,{c参数} 的字符串中也存在 ,{ ,导致规则切错

修复<str0,str2,...{{js}}>这种页数列表写法中,js部分内含 < 或 > 就会切割错误的问题

优化格式化图片标签操作和匹配图片标签操作,加快图片处理速度
pull/1118/head
bushixuanqi 3 years ago
parent 276345fed4
commit f838497c88
  1. 4
      app/src/main/java/io/legado/app/utils/HtmlFormatter.kt

@ -25,12 +25,12 @@ object HtmlFormatter {
val sb = StringBuffer()
//图片有data-开头的数据属性时优先用数据属性作为src,没有数据属性时匹配src
val imgPatternX = Pattern.compile(
val imgPattern = Pattern.compile(
if(keepImgHtml.matches("<img[^>]*data-".toRegex())) "<img[^>]*data-[^=]*= *\"([^\"])\"[^>]*>"
else "<img[^>]*src *= *\"([^\"{]+(?:\\{(?:[^{}]|\\{[^{}]*\\})*\\})?)\"[^>]*>", Pattern.CASE_INSENSITIVE
)
val matcher = imgPatternX.matcher(keepImgHtml)
val matcher = imgPattern.matcher(keepImgHtml)
var appendPos = 0
while (matcher.find()) {
sb.append(keepImgHtml.substring(appendPos, matcher.start()))

Loading…
Cancel
Save