This commit is contained in:
Horis
2024-07-07 07:20:45 +08:00
parent 902767ad6e
commit c6ad1a8053
2 changed files with 23 additions and 0 deletions
@@ -97,6 +97,7 @@ interface BaseSource : JsExtensions {
* 解析header规则
*/
fun getHeaderMap(hasLoginHeader: Boolean = false) = HashMap<String, String>().apply {
if (checkRhinoRecursiveCall()) return@apply
header?.let {
GSON.fromJsonObject<Map<String, String>>(
when {
@@ -0,0 +1,22 @@
package io.legado.app.utils
import org.mozilla.javascript.Context
private val enterCountField by lazy {
Context::class.java.getDeclaredField("enterCount").apply {
isAccessible = true
}
}
fun Context?.getEnterCount(): Int {
this ?: return 0
return enterCountField.get(this) as Int
}
fun checkRhinoRecursiveCall(): Boolean {
return Context.getCurrentContext().getEnterCount() > 1
}
fun checkRhinoCall(): Boolean {
return Context.getCurrentContext() != null
}