mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
43d3fdcf61
commit
50bf32a99a
@ -36,6 +36,7 @@ import org.apache.commons.text.StringEscapeUtils
|
|||||||
import org.jsoup.Jsoup
|
import org.jsoup.Jsoup
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
import java.net.URLDecoder
|
import java.net.URLDecoder
|
||||||
|
import java.util.regex.PatternSyntaxException
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rss阅读界面
|
* rss阅读界面
|
||||||
@ -346,26 +347,34 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
|
|||||||
request: WebResourceRequest
|
request: WebResourceRequest
|
||||||
): WebResourceResponse? {
|
): WebResourceResponse? {
|
||||||
val url = request.url.toString()
|
val url = request.url.toString()
|
||||||
viewModel.rssSource?.let { source ->
|
val source = viewModel.rssSource ?: return super.shouldInterceptRequest(view, request)
|
||||||
val blacklist = source.contentBlacklist?.splitNotBlank(",")
|
val blacklist = source.contentBlacklist?.splitNotBlank(",")
|
||||||
if (!blacklist.isNullOrEmpty()) {
|
if (!blacklist.isNullOrEmpty()) {
|
||||||
blacklist.forEach {
|
blacklist.forEach {
|
||||||
|
try {
|
||||||
if (url.startsWith(it) || url.matches(it.toRegex())) {
|
if (url.startsWith(it) || url.matches(it.toRegex())) {
|
||||||
return createEmptyResource()
|
return createEmptyResource()
|
||||||
}
|
}
|
||||||
|
} catch (e: PatternSyntaxException) {
|
||||||
|
AppLog.put("黑名单规则正则语法错误 源名称:${source.sourceName} 正则:$it", e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val whitelist = source.contentWhitelist?.splitNotBlank(",")
|
val whitelist = source.contentWhitelist?.splitNotBlank(",")
|
||||||
if (!whitelist.isNullOrEmpty()) {
|
if (!whitelist.isNullOrEmpty()) {
|
||||||
whitelist.forEach {
|
whitelist.forEach {
|
||||||
|
try {
|
||||||
if (url.startsWith(it) || url.matches(it.toRegex())) {
|
if (url.startsWith(it) || url.matches(it.toRegex())) {
|
||||||
return super.shouldInterceptRequest(view, request)
|
return super.shouldInterceptRequest(view, request)
|
||||||
}
|
}
|
||||||
|
} catch (e: PatternSyntaxException) {
|
||||||
|
val msg = "白名单规则正则语法错误 源名称:${source.sourceName} 正则:$it"
|
||||||
|
AppLog.put(msg, e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return createEmptyResource()
|
return createEmptyResource()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return super.shouldInterceptRequest(view, request)
|
return super.shouldInterceptRequest(view, request)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user