fix(HtmlFormatter.kt): 限制img正则

src属性前必须有个空格,可能会命中错误
<img src="....." zy-enlarge-src="none">
close #3215
This commit is contained in:
Xwite
2023-07-11 18:45:24 +08:00
committed by GitHub
parent ddd3d8b15b
commit 3e624ef62b
@@ -17,7 +17,7 @@ object HtmlFormatter {
private val notImgHtmlRegex = "</?(?!img)[a-zA-Z]+(?=[ >])[^<>]*>".toRegex()
private val otherHtmlRegex = "</?[a-zA-Z]+(?=[ >])[^<>]*>".toRegex()
private val formatImagePattern = Pattern.compile(
"<img[^>]*src *= *\"([^\"{>]*\\{(?:[^{}]|\\{[^}>]+\\})+\\})\"[^>]*>|<img[^>]*data-[^=>]*= *\"([^\">]*)\"[^>]*>|<img[^>]*src *= *\"([^\">]*)\"[^>]*>",
"<img[^>]* src *= *\"([^\"{>]*\\{(?:[^{}]|\\{[^}>]+\\})+\\})\"[^>]*>|<img[^>]* data-[^=>]*= *\"([^\">]*)\"[^>]*>|<img[^>]* src *= *\"([^\">]*)\"[^>]*>",
Pattern.CASE_INSENSITIVE
)