refactor: use Jsoup XmlParser instead of HTML parser where needed

This commit is contained in:
Gauthier Roebroeck 2025-08-20 13:41:42 +08:00
parent 8b629888ff
commit 4e7c49d5d8
2 changed files with 3 additions and 2 deletions

View file

@ -30,7 +30,7 @@ inline fun <R> Path.epub(block: (EpubPackage) -> R): R =
*/
fun ZipFile.getPackagePath(): String =
getEntryInputStream("META-INF/container.xml")
?.use { Jsoup.parse(it, null, "") }
?.use { Jsoup.parse(it, null, "", Parser.xmlParser()) }
?.getElementsByTag("rootfile")
?.first()
?.attr("full-path") ?: throw MediaUnsupportedException("META-INF/container.xml does not contain rootfile tag")

View file

@ -4,6 +4,7 @@ import org.gotson.komga.domain.model.EpubTocEntry
import org.gotson.komga.infrastructure.util.getEntryBytes
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
import org.jsoup.parser.Parser
import java.net.URLDecoder
import java.nio.file.Path
import kotlin.io.path.Path
@ -23,7 +24,7 @@ fun processNcx(
navType: Epub2Nav,
): List<EpubTocEntry> =
Jsoup
.parse(document.content)
.parse(document.content, "", Parser.xmlParser())
.select("${navType.level1} > ${navType.level2}")
.toList()
.mapNotNull { ncxElementToTocEntry(navType, it, document.path.parent) }