pull/2692/head
Horis 2 years ago
parent 942f98ce5c
commit ac9915ec36
  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 okhttp3.Response
import org.intellij.lang.annotations.Language import org.intellij.lang.annotations.Language
import org.jsoup.Jsoup import org.jsoup.Jsoup
import org.jsoup.parser.Parser
import java.io.File import java.io.File
import java.io.FileOutputStream import java.io.FileOutputStream
import java.io.InputStream import java.io.InputStream
@ -150,7 +151,7 @@ open class WebDav(val path: String, val authorization: Authorization) {
*/ */
private fun parseBody(s: String): List<WebDavFile> { private fun parseBody(s: String): List<WebDavFile> {
val list = ArrayList<WebDavFile>() val list = ArrayList<WebDavFile>()
val document = Jsoup.parse(s) val document = Jsoup.parse(s, Parser.xmlParser())
val ns = document.findNSPrefix("DAV:") val ns = document.findNSPrefix("DAV:")
val elements = document.findNS("response", ns) val elements = document.findNS("response", ns)
val urlStr = httpUrl ?: return list val urlStr = httpUrl ?: return list

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

@ -420,6 +420,12 @@ class AnalyzeUrl(
} }
else -> get(urlNoQuery, fieldMap, true) 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 return strResponse

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

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

Loading…
Cancel
Save