diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt index cf11dbb72..38fb633c5 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByJSoup.kt @@ -359,8 +359,7 @@ class AnalyzeByJSoup { try { when (lastRule) { "text" -> for (element in elements) { - val text = element.text() - textS.add(text) + textS.add(element.text()) } "textNodes" -> for (element in elements) { val tn = arrayListOf() @@ -373,12 +372,15 @@ class AnalyzeByJSoup { } textS.add(join("\n", tn)) } - "ownText", "html" -> { - elements.select("script").remove() + "ownText" -> for (element in elements) { + textS.add(element.ownText()) + } + "html" -> { + elements.select("script, style").remove() val html = elements.html() textS.add(html) } - "all" -> textS.add(elements.html()) + "all" -> textS.add(elements.outerHtml()) else -> for (element in elements) { val url = element.attr(lastRule) if (!isEmpty(url) && !textS.contains(url)) { diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index 19d4edb50..f9dbba8ee 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -8,6 +8,7 @@ import io.legado.app.data.entities.BaseBook import io.legado.app.data.entities.BookChapter import io.legado.app.help.JsExtensions import io.legado.app.utils.* +import org.jsoup.nodes.Entities import org.mozilla.javascript.NativeObject import java.util.* import java.util.regex.Pattern @@ -206,7 +207,7 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { else -> sourceRule.rule } } - if (sourceRule.replaceRegex.isNotEmpty()) { + if ((result != null) && sourceRule.replaceRegex.isNotEmpty()) { result = replaceRegex(result.toString(), sourceRule) } } @@ -214,10 +215,15 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions { } } if (result == null) result = "" + val str = try { + Entities.unescape(result.toString()) + } catch (e: Exception) { + result.toString() + } if (isUrl) { - return NetworkUtils.getAbsoluteURL(baseUrl, result.toString()) ?: "" + return NetworkUtils.getAbsoluteURL(baseUrl, str) ?: "" } - return result.toString() + return str } /** diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt index d5d9b9b66..c68db66a1 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt @@ -77,15 +77,10 @@ class ReadRssActivity : VMBaseActivity(R.layout.activity_rss_r val url = NetworkUtils.getAbsoluteURL(it.origin, it.link) val html = viewModel.clHtml(content) if (viewModel.rssSource?.loadWithBaseUrl == true) { - webView.loadDataWithBaseURL( - url, - html, - "text/html", - "utf-8", - url - )//不想用baseUrl进else + webView.loadDataWithBaseURL(url, html, "text/html", "utf-8", url)//不想用baseUrl进else } else { - webView.loadData(html, "text/html;charset=utf-8", "utf-8")//经测试可以解决中文乱码 + //webView.loadData(html, "text/html;charset=utf-8", "utf-8")//经测试可以解决中文乱码 + webView.loadDataWithBaseURL(null, html, "text/html;charset=utf-8", "utf-8", url) } } }) diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt index 0ace44358..17b66f41c 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt @@ -86,7 +86,7 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application), } fun clHtml(content: String): String { - return if (content.contains("