improve global context enumeration under sandbox (#4812)

fixes #4811
This commit is contained in:
Alex Lam S.L
2021-03-22 14:43:33 +00:00
committed by GitHub
parent 9c01511f84
commit 51bdb7281b
3 changed files with 57 additions and 4 deletions

View File

@@ -170,6 +170,12 @@ function setup(global, builtins, setup_log, setup_tty) {
},
global: { get: self },
self: { get: self },
// for Node.js v8+
toString: {
get: function() {
return global_toString;
},
},
window: { get: self },
};
[
@@ -199,15 +205,15 @@ function setup(global, builtins, setup_log, setup_tty) {
} catch (e) {}
});
Object.defineProperties(global, props);
// for Node.js v8+
global.toString = function() {
return "[object global]";
};
function self() {
return this;
}
function global_toString() {
return "[object global]";
}
function safe_log(arg, cache) {
if (arg) switch (typeof arg) {
case "function":