优化
This commit is contained in:
@@ -10,6 +10,7 @@ import io.legado.app.data.entities.BookChapter
|
||||
import io.legado.app.help.book.BookHelp
|
||||
import io.legado.app.utils.FileUtils
|
||||
import io.legado.app.utils.HtmlFormatter
|
||||
import io.legado.app.utils.encodeURI
|
||||
import io.legado.app.utils.isXml
|
||||
import io.legado.app.utils.printOnDebug
|
||||
import me.ag2s.epublib.domain.EpubBook
|
||||
@@ -252,8 +253,10 @@ class EpubFile(var book: Book) {
|
||||
}
|
||||
}
|
||||
bodyElement.select("img").forEach {
|
||||
val src = it.attr("src")
|
||||
it.attr("src", URI(res.href).resolve(src).toString())
|
||||
val src = it.attr("src").encodeURI()
|
||||
val href = res.href.encodeURI()
|
||||
val resolvedHref = URLDecoder.decode(URI(href).resolve(src).toString(), "UTF-8")
|
||||
it.attr("src", resolvedHref)
|
||||
}
|
||||
return bodyElement
|
||||
}
|
||||
|
||||
@@ -7,12 +7,13 @@ import android.icu.text.Collator
|
||||
import android.icu.util.ULocale
|
||||
import android.net.Uri
|
||||
import android.text.Editable
|
||||
import cn.hutool.core.net.URLEncodeUtil
|
||||
import io.legado.app.constant.AppPattern
|
||||
import io.legado.app.constant.AppPattern.dataUriRegex
|
||||
import java.io.File
|
||||
import java.lang.Character.codePointCount
|
||||
import java.lang.Character.offsetByCodePoints
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
import java.util.regex.Pattern
|
||||
|
||||
fun String?.safeTrim() = if (this.isNullOrBlank()) null else this.trim()
|
||||
@@ -132,3 +133,4 @@ fun String.escapeRegex(): String {
|
||||
return replace(AppPattern.regexCharRegex, "\\\\$0")
|
||||
}
|
||||
|
||||
fun String.encodeURI(): String = URLEncodeUtil.encodeQuery(this)
|
||||
|
||||
Reference in New Issue
Block a user