fix(epub): some TOC may not be parsed correctly

This commit is contained in:
Gauthier Roebroeck 2026-04-13 10:13:26 +08:00
parent dd9c3facd7
commit 5fc0b7ef30
2 changed files with 4 additions and 2 deletions

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
@ -20,7 +21,7 @@ fun processNav(
document: ResourceContent,
navElement: Epub3Nav,
): List<EpubTocEntry> {
val doc = Jsoup.parse(document.content)
val doc = Jsoup.parse(document.content, "", Parser.xmlParser())
val nav =
doc
.select("nav")

View file

@ -3,6 +3,7 @@ package org.gotson.komga.infrastructure.mediacontainer.epub
import org.assertj.core.api.Assertions.assertThat
import org.gotson.komga.domain.model.EpubTocEntry
import org.jsoup.Jsoup
import org.jsoup.parser.Parser
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.ValueSource
import org.springframework.core.io.ClassPathResource
@ -15,7 +16,7 @@ class OpfTest {
// given
val opfResource = ClassPathResource("epub/clash.opf")
val opfString = opfResource.inputStream.readAllBytes().decodeToString()
val opfDoc = Jsoup.parse(opfString)
val opfDoc = Jsoup.parse(opfString, "", Parser.xmlParser())
// when
val opfLandmarks = processOpfGuide(opfDoc, if (prefix.isBlank()) null else Path.of(prefix))