From 824bd89edeb1d453a120c6883b096e7e5a4c6a28 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Wed, 3 Jan 2024 03:34:43 +0800 Subject: [PATCH] fix: fix a bug which script not support makeTransferable json which data include null for example: {a: null} --- src/server/utils/sandbox.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/server/utils/sandbox.ts b/src/server/utils/sandbox.ts index 611ddec..2f9ddf0 100644 --- a/src/server/utils/sandbox.ts +++ b/src/server/utils/sandbox.ts @@ -9,10 +9,12 @@ function isTransferable(data: any): data is ivm.Transferable { return true; } + if (data === null) { + return true; + } + if ( - ['null', 'undefined', 'string', 'number', 'boolean', 'function'].includes( - dataType - ) + ['undefined', 'string', 'number', 'boolean', 'function'].includes(dataType) ) { return true; }