From fed877a860bd4a45429ac930a33b1998b66810f8 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Tue, 15 Mar 2022 11:20:48 +0800 Subject: [PATCH] fix: include all non-enumerable globals in global scope --- eval.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/eval.js b/eval.js index e603f17..76ad90f 100644 --- a/eval.js +++ b/eval.js @@ -5,7 +5,9 @@ var requireLike = require('require-like') function merge (a, b) { if (!a || !b) return a - var keys = Object.keys(b) + // Include all non-enumerable variables, including console (v10+), + // process (v12+), URL, etc. + var keys = Object.getOwnPropertyNames(b) for (var k, i = 0, n = keys.length; i < n; i++) { k = keys[i] a[k] = b[k] @@ -36,11 +38,6 @@ module.exports = function (content, filename, scope, includeGlobals) { if (includeGlobals) { merge(sandbox, global) - // console is non-enumerable in node v10 and above - sandbox.console = global.console - // process is non-enumerable in node v12 and above - sandbox.process = global.process - sandbox.URL = global.URL sandbox.require = requireLike(_filename) }