From 13abbe276d6709d2902ad342bd4bcee0f7f8b356 Mon Sep 17 00:00:00 2001 From: ag2s20150909 Date: Mon, 12 Jul 2021 22:51:25 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0jsoup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 19db5b208..4cedca019 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -168,7 +168,7 @@ dependencies { implementation 'io.github.jeremyliao:live-event-bus-x:1.8.0' //规则相关 - implementation 'org.jsoup:jsoup:1.13.1' + implementation 'org.jsoup:jsoup:1.14.1' //noinspection GradleDependency implementation 'cn.wanghaomiao:JsoupXpath:2.3.2' implementation 'com.jayway.jsonpath:json-path:2.6.0' @@ -205,4 +205,4 @@ dependencies { //转换繁体 implementation 'com.github.liuyueyi.quick-chinese-transfer:quick-transfer-core:0.2.1' -} \ No newline at end of file +} From 87e279ecf45bca850d42c8c6120a77527fa2c2ac Mon Sep 17 00:00:00 2001 From: ag2s20150909 Date: Wed, 14 Jul 2021 19:31:44 +0800 Subject: [PATCH 2/5] =?UTF-8?q?Fix:=E6=B7=BB=E5=8A=A0js=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E6=9D=A5=E4=BF=AE=E5=A4=8D=E5=BC=80=E5=90=AFjs=E6=B2=99?= =?UTF-8?q?=E7=AE=B1=E5=90=8E=E6=9F=90=E4=BA=9B=E4=B9=A6=E6=BA=90=E5=A4=B1?= =?UTF-8?q?=E6=95=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getZipStringContent(url: String, path: String): String getZipByteArrayContent(url: String, path: String): ByteArray --- .../java/io/legado/app/help/JsExtensions.kt | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index 64fb8d954..cab0b6d96 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -15,9 +15,13 @@ import kotlinx.coroutines.runBlocking import org.jsoup.Connection import org.jsoup.Jsoup import splitties.init.appCtx +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream import java.io.File import java.net.URLEncoder import java.util.* +import java.util.zip.ZipEntry +import java.util.zip.ZipInputStream @Keep @Suppress("unused") @@ -275,6 +279,59 @@ interface JsExtensions { return null } + /** + * 获取网络zip文件里面的数据 + * @param url zip文件的链接 + * @param path 所需获取文件在zip内的路径 + * @return zip指定文件的数据 + */ + fun getZipStringContent(url: String, path: String): String { + val bytes = runBlocking { + return@runBlocking okHttpClient.newCall { url(url) }.bytes() + } + val bos = ByteArrayOutputStream() + val zis = ZipInputStream(ByteArrayInputStream(bytes)) + + var entry: ZipEntry = zis.nextEntry + + while (entry != null) { + if (entry.name.equals(path)) { + zis.use { it.copyTo(bos) } + return bos.toString() + } + entry = zis.nextEntry + } + Debug.log("getZipContent 未发现内容") + + return ""; + } + + /** + * 获取网络zip文件里面的数据 + * @param url zip文件的链接 + * @param path 所需获取文件在zip内的路径 + * @return zip指定文件的数据 + */ + fun getZipByteArrayContent(url: String, path: String): ByteArray? { + val bytes = runBlocking { + return@runBlocking okHttpClient.newCall { url(url) }.bytes() + } + val bos = ByteArrayOutputStream() + val zis = ZipInputStream(ByteArrayInputStream(bytes)) + + var entry: ZipEntry = zis.nextEntry + while (entry != null) { + if (entry.name.equals(path)) { + zis.use { it.copyTo(bos) } + return bos.toByteArray() + } + entry = zis.nextEntry; + } + Debug.log("getZipContent 未发现内容") + + return null; + } + /** * 返回字体解析类 * @param str 支持url,本地文件,base64,自动判断,自动缓存 From 8410d1f3b73dc0bc4412d8411365be9dc18197a3 Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 14 Jul 2021 22:35:24 +0800 Subject: [PATCH 3/5] edit updateLog.md --- app/src/main/assets/updateLog.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 210e30e78..00a06a045 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -8,6 +8,26 @@ * 正文出现缺字漏字、内容缺失、排版错乱等情况,有可能是净化规则出现问题。先关闭替换净化并刷新,再观察是否正常。如果正常说明净化规则存在误杀,如果关闭后仍然出现相关问题,请点击源链接查看原文与正文是否相同,如果不同,再进行反馈。 * 漫画源看书显示乱码,**阅读与其他软件的源并不通用**,请导入阅读的支持的漫画源! +**2021/07/15** +1. 添加js函数来修复开启js沙箱后某些书源失效。by ag2s20150909 +```kotlin +/** +* 获取网络zip文件里面的数据 +* @param url zip文件的链接 +* @param path 所需获取文件在zip内的路径 +* @return zip指定文件的数据 +*/ +fun getZipStringContent(url: String, path: String): String +/** +* 获取网络zip文件里面的数据 +* @param url zip文件的链接 +* @param path 所需获取文件在zip内的路径 +* @return zip指定文件的数据 +*/ +fun getZipByteArrayContent(url: String, path: String): ByteArray? +``` +* web服务添加一个导航页 + **2021/07/11** 1. 开启JS沙箱限制 * 禁止在js里exec运行命令 From abc2d47af7b5dc7004110c1f9abe00ff25c2594d Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 14 Jul 2021 22:55:03 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/JsExtensions.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index cab0b6d96..9a178f4be 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -303,7 +303,7 @@ interface JsExtensions { } Debug.log("getZipContent 未发现内容") - return ""; + return "" } /** @@ -325,11 +325,11 @@ interface JsExtensions { zis.use { it.copyTo(bos) } return bos.toByteArray() } - entry = zis.nextEntry; + entry = zis.nextEntry } Debug.log("getZipContent 未发现内容") - return null; + return null } /** From c898d6407ee3e44c6db63e2347b69363999eab7c Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 14 Jul 2021 23:05:38 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/JsExtensions.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/JsExtensions.kt b/app/src/main/java/io/legado/app/help/JsExtensions.kt index 9a178f4be..1f464db47 100644 --- a/app/src/main/java/io/legado/app/help/JsExtensions.kt +++ b/app/src/main/java/io/legado/app/help/JsExtensions.kt @@ -292,7 +292,7 @@ interface JsExtensions { val bos = ByteArrayOutputStream() val zis = ZipInputStream(ByteArrayInputStream(bytes)) - var entry: ZipEntry = zis.nextEntry + var entry: ZipEntry? = zis.nextEntry while (entry != null) { if (entry.name.equals(path)) { @@ -319,7 +319,7 @@ interface JsExtensions { val bos = ByteArrayOutputStream() val zis = ZipInputStream(ByteArrayInputStream(bytes)) - var entry: ZipEntry = zis.nextEntry + var entry: ZipEntry? = zis.nextEntry while (entry != null) { if (entry.name.equals(path)) { zis.use { it.copyTo(bos) }