mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
Some checks are pending
Test Build / prepare (push) Waiting to run
Test Build / build (app, release) (push) Blocked by required conditions
Test Build / build (app, releaseA) (push) Blocked by required conditions
Test Build / prerelease (push) Blocked by required conditions
Test Build / lanzou (push) Blocked by required conditions
Test Build / test_Branch (push) Blocked by required conditions
Test Build / telegram (push) Blocked by required conditions
Some checks are pending
Test Build / prepare (push) Waiting to run
Test Build / build (app, release) (push) Blocked by required conditions
Test Build / build (app, releaseA) (push) Blocked by required conditions
Test Build / prerelease (push) Blocked by required conditions
Test Build / lanzou (push) Blocked by required conditions
Test Build / test_Branch (push) Blocked by required conditions
Test Build / telegram (push) Blocked by required conditions
This commit is contained in:
@@ -216,4 +216,12 @@ class App : Application() {
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
init {
|
||||
if (BuildConfig.DEBUG) {
|
||||
System.setProperty("kotlinx.coroutines.debug", "on")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ object ReadManga : CoroutineScope by MainScope() {
|
||||
mCallback?.loadFail(errorMsg)
|
||||
return
|
||||
}
|
||||
if (content.isEmpty()) {
|
||||
if (content.isEmpty() && !chapter.isVolume) {
|
||||
mCallback?.loadFail("正文内容为空")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ dependencies {
|
||||
api libs.mozilla.rhino
|
||||
|
||||
implementation(libs.kotlinx.coroutines.core)
|
||||
implementation(libs.okhttp)
|
||||
|
||||
// def coroutines_version = '1.7.3'
|
||||
// implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version")
|
||||
|
||||
@@ -24,7 +24,14 @@
|
||||
*/
|
||||
package com.script.rhino
|
||||
|
||||
import android.os.Build
|
||||
import org.mozilla.javascript.ClassShutter
|
||||
import org.mozilla.javascript.Context
|
||||
import java.io.ObjectInputStream
|
||||
import java.io.ObjectOutputStream
|
||||
import java.lang.reflect.Member
|
||||
import java.nio.file.FileSystem
|
||||
import java.nio.file.Path
|
||||
|
||||
/**
|
||||
* This class prevents script access to certain sensitive classes.
|
||||
@@ -38,30 +45,75 @@ object RhinoClassShutter : ClassShutter {
|
||||
|
||||
private val protectedClasses by lazy {
|
||||
hashSetOf(
|
||||
"dalvik.system",
|
||||
"java.lang.Class",
|
||||
"java.lang.ClassLoader",
|
||||
"java.net.URLClassLoader",
|
||||
"cn.hutool.core.lang.JarClassLoader",
|
||||
"cn.hutool.core.util.RuntimeUtil",
|
||||
"cn.hutool.core.util.ClassLoaderUtil",
|
||||
"org.mozilla.javascript.DefiningClassLoader",
|
||||
"java.lang.Runtime",
|
||||
"java.lang.ProcessBuilder",
|
||||
"java.lang.ProcessImpl",
|
||||
"java.lang.UNIXProcess",
|
||||
"java.io.File",
|
||||
"java.io.FileInputStream",
|
||||
"java.io.FileOutputStream",
|
||||
"java.io.FileReader",
|
||||
"java.io.FileWriter",
|
||||
"java.io.RandomAccessFile",
|
||||
"java.io.ObjectInputStream",
|
||||
"java.io.ObjectOutputStream",
|
||||
"java.security.AccessController",
|
||||
"java.nio.file.Paths",
|
||||
"java.nio.file.Files",
|
||||
"java.nio.file.FileSystems",
|
||||
"io.legado.app.data.AppDatabase",
|
||||
"io.legado.app.data.AppDatabaseKt",
|
||||
"io.legado.app.utils.ContextExtensionsKt",
|
||||
"android.content.Intent",
|
||||
"androidx.core.content.FileProvider",
|
||||
"android.provider.Settings",
|
||||
"androidx.sqlite.db",
|
||||
"splitties.init.AppCtxKt",
|
||||
"android.app.ActivityThread",
|
||||
"android.app.AppGlobals"
|
||||
"android.app.AppGlobals",
|
||||
"okio.JvmSystemFileSystem",
|
||||
"okio.JvmFileHandle",
|
||||
"okio.NioSystemFileSystem",
|
||||
"okio.NioFileSystemFileHandle",
|
||||
"okio.Path",
|
||||
|
||||
"android.system",
|
||||
"android.database",
|
||||
"androidx.sqlite.db",
|
||||
"cn.hutool.core.io",
|
||||
"dalvik.system",
|
||||
"java.nio.file",
|
||||
)
|
||||
}
|
||||
|
||||
fun visibleToScripts(obj: Any): Boolean {
|
||||
when (obj) {
|
||||
is ClassLoader,
|
||||
is Class<*>,
|
||||
is Member,
|
||||
is Context,
|
||||
is ObjectInputStream,
|
||||
is ObjectOutputStream,
|
||||
is okio.FileSystem,
|
||||
is okio.FileHandle,
|
||||
is okio.Path,
|
||||
is android.content.Context -> return false
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
when (obj) {
|
||||
is FileSystem,
|
||||
is Path -> return false
|
||||
}
|
||||
}
|
||||
return visibleToScripts(obj.javaClass.name)
|
||||
}
|
||||
|
||||
override fun visibleToScripts(fullClassName: String): Boolean {
|
||||
if (!protectedClasses.contains(fullClassName)) {
|
||||
var className = fullClassName
|
||||
|
||||
@@ -27,7 +27,6 @@ package com.script.rhino
|
||||
import org.mozilla.javascript.Context
|
||||
import org.mozilla.javascript.Scriptable
|
||||
import org.mozilla.javascript.WrapFactory
|
||||
import java.lang.reflect.Member
|
||||
|
||||
/**
|
||||
* This wrap factory is used for security reasons. JSR 223 script
|
||||
@@ -50,25 +49,10 @@ object RhinoWrapFactory : WrapFactory() {
|
||||
javaObject: Any,
|
||||
staticType: Class<*>?
|
||||
): Scriptable? {
|
||||
val classShutter = RhinoClassShutter
|
||||
return when (javaObject) {
|
||||
is ClassLoader,
|
||||
is Class<*>,
|
||||
is Member,
|
||||
is Context,
|
||||
is android.content.Context -> {
|
||||
null
|
||||
}
|
||||
|
||||
else -> {
|
||||
val name = javaObject.javaClass.name
|
||||
if (classShutter.visibleToScripts(name)) {
|
||||
super.wrapAsJavaObject(cx, scope, javaObject, staticType)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
if (!RhinoClassShutter.visibleToScripts(javaObject)) {
|
||||
return null
|
||||
}
|
||||
return super.wrapAsJavaObject(cx, scope, javaObject, staticType)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user