|
|
@ -32,7 +32,7 @@ object HtmlFormatter { |
|
|
|
var hasMatch = true //普通图片标签是否还未处理过 |
|
|
|
var hasMatch = true //普通图片标签是否还未处理过 |
|
|
|
var hasMatchX = false //是否存在带参数或带数据属性的图片标签 |
|
|
|
var hasMatchX = false //是否存在带参数或带数据属性的图片标签 |
|
|
|
var pos = -1 |
|
|
|
var pos = -1 |
|
|
|
val list = listOf("<img[^>]*src *= *\"([^\"{]+\\{(?:[^{}]|\\{[^}]+\\})+\\})\"[^>]*>","<img[^>]*data-[^=]*= *\"([^\"]+)\"[^>]*>","<img[^>]*src *= *\"([^\"]+)\"[^>]*>") //优先匹配用户处理过所以带参数的图片标签,其次匹配带数据属性的图片标签 |
|
|
|
val list = listOf("<img[^>]*src *= *\"([^\"]+,\\s*\\{(?:[^{}]|\\{[^}]+\\})+\\})\"[^>]*>","<img[^>]*data-[^=]*= *\"([^\"]+)\"[^>]*>","<img[^>]*src *= *\"([^\"]+)\"[^>]*>") //优先匹配用户处理过所以带参数的图片标签,其次匹配带数据属性的图片标签 |
|
|
|
while(++pos<3){ |
|
|
|
while(++pos<3){ |
|
|
|
if(pos == 2) { |
|
|
|
if(pos == 2) { |
|
|
|
if(hasMatchX)break //普通图片标签只在不存在存在带参数或带数据属性的图片标签的时候匹配 |
|
|
|
if(hasMatchX)break //普通图片标签只在不存在存在带参数或带数据属性的图片标签的时候匹配 |
|
|
@ -60,8 +60,7 @@ object HtmlFormatter { |
|
|
|
if (pos == 0) { |
|
|
|
if (pos == 0) { |
|
|
|
val url = matcher.group(1)!! |
|
|
|
val url = matcher.group(1)!! |
|
|
|
val urlMatcher = AnalyzeUrl.paramPattern.matcher(url) |
|
|
|
val urlMatcher = AnalyzeUrl.paramPattern.matcher(url) |
|
|
|
if(urlMatcher.find()) NetworkUtils.getAbsoluteURL(redirectUrl,url.substring(0,urlMatcher.start())) + ',' + url.substring(urlMatcher.end()) |
|
|
|
NetworkUtils.getAbsoluteURL(redirectUrl,url.substring(0,urlMatcher.start())) + ',' + url.substring(urlMatcher.end()) |
|
|
|
else NetworkUtils.getAbsoluteURL(redirectUrl,url) |
|
|
|
|
|
|
|
}else NetworkUtils.getAbsoluteURL(redirectUrl,matcher.group(1)!!) |
|
|
|
}else NetworkUtils.getAbsoluteURL(redirectUrl,matcher.group(1)!!) |
|
|
|
}\">") |
|
|
|
}\">") |
|
|
|
|
|
|
|
|
|
|
|