Merge remote-tracking branch 'origin/master'

pull/2692/head
kunfei 2 years ago
commit a65a2b95fd
  1. 3
      app/src/main/java/io/legado/app/lib/webdav/WebDav.kt
  2. 5
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByXPath.kt
  3. 6
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt
  4. 8
      app/src/main/java/io/legado/app/model/localBook/EpubFile.kt
  5. 2
      app/src/main/java/io/legado/app/ui/book/cache/CacheViewModel.kt

@ -17,6 +17,7 @@ import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import org.intellij.lang.annotations.Language
import org.jsoup.Jsoup
import org.jsoup.parser.Parser
import java.io.File
import java.io.FileOutputStream
import java.io.InputStream
@ -150,7 +151,7 @@ open class WebDav(val path: String, val authorization: Authorization) {
*/
private fun parseBody(s: String): List<WebDavFile> {
val list = ArrayList<WebDavFile>()
val document = Jsoup.parse(s)
val document = Jsoup.parse(s, Parser.xmlParser())
val ns = document.findNSPrefix("DAV:")
val elements = document.findNS("response", ns)
val urlStr = httpUrl ?: return list

@ -2,8 +2,10 @@ package io.legado.app.model.analyzeRule
import android.text.TextUtils
import androidx.annotation.Keep
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import org.jsoup.parser.Parser
import org.jsoup.select.Elements
import org.seimicrawler.xpath.JXDocument
import org.seimicrawler.xpath.JXNode
@ -30,6 +32,9 @@ class AnalyzeByXPath(doc: Any) {
if (html1.endsWith("</tr>") || html1.endsWith("</tbody>")) {
html1 = "<table>${html1}</table>"
}
if (html1.trim().startsWith("<?xml", true)) {
return JXDocument.create(Jsoup.parse(html1, Parser.xmlParser()))
}
return JXDocument.create(html1)
}

@ -420,6 +420,12 @@ class AnalyzeUrl(
}
else -> get(urlNoQuery, fieldMap, true)
}
}.let {
val isXml = it.raw.body?.contentType()?.toString()
?.matches("(application|text)/\\w*\\+?xml.*".toRegex()) == true
if (isXml && it.body?.trim()?.startsWith("<?xml", true) == false) {
StrResponse(it.raw, "<?xml version=\"1.0\"?>" + it.body)
} else it
}
}
return strResponse

@ -13,11 +13,11 @@ import me.ag2s.epublib.domain.EpubBook
import me.ag2s.epublib.domain.Resource
import me.ag2s.epublib.domain.TOCReference
import me.ag2s.epublib.epub.EpubReader
import me.ag2s.epublib.util.StringUtil
import me.ag2s.epublib.util.zip.AndroidZipFile
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
import splitties.init.appCtx
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
@ -173,6 +173,12 @@ class EpubFile(var book: Book) {
}
//title标签中的内容不需要显示在正文中,去除
elements.select("title").remove()
elements.select("img").forEach {
val src = it.attr("src")
val path = chapter.url.substringBeforeLast("/") + "/"
val absSrc = StringUtil.collapsePathDots(path + src)
it.attr("src", absSrc)
}
var html = elements.outerHtml()
val tag = Book.rubyTag
if (book.getDelTag(tag)) {

@ -227,7 +227,7 @@ class CacheViewModel(application: Application) : BaseViewModel(application) {
.getContent(
book,
chapter,
content ?: "null",
content ?: if (chapter.isVolume) "" else "null",
includeTitle = !AppConfig.exportNoChapterName,
useReplace = useReplace,
chineseConvert = false,

Loading…
Cancel
Save