This commit is contained in:
Horis
2024-07-07 07:32:26 +08:00
parent c6ad1a8053
commit c6bb853624
2 changed files with 9 additions and 5 deletions

View File

@@ -97,7 +97,7 @@ interface BaseSource : JsExtensions {
* 解析header规则
*/
fun getHeaderMap(hasLoginHeader: Boolean = false) = HashMap<String, String>().apply {
if (checkRhinoRecursiveCall()) return@apply
checkRhinoRecursiveCall()
header?.let {
GSON.fromJsonObject<Map<String, String>>(
when {

View File

@@ -13,10 +13,14 @@ fun Context?.getEnterCount(): Int {
return enterCountField.get(this) as Int
}
fun checkRhinoRecursiveCall(): Boolean {
return Context.getCurrentContext().getEnterCount() > 1
fun checkRhinoRecursiveCall() {
check(Context.getCurrentContext().getEnterCount() <= 1) {
"Rhino recursive call detected."
}
}
fun checkRhinoCall(): Boolean {
return Context.getCurrentContext() != null
fun checkRhinoCall() {
check(Context.getCurrentContext() == null) {
"Rhino call detected."
}
}