diff options
Diffstat (limited to 'runtime/js/99_main.js')
-rw-r--r-- | runtime/js/99_main.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 1af2585a5..67667427f 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -1,9 +1,5 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -// Removes the `__proto__` for security reasons. -// https://tc39.es/ecma262/#sec-get-object.prototype.__proto__ -delete Object.prototype.__proto__; - // Remove Intl.v8BreakIterator because it is a non-standard API. delete Intl.v8BreakIterator; @@ -14,6 +10,7 @@ const primordials = globalThis.__bootstrap.primordials; const { ArrayPrototypeFilter, ArrayPrototypeIndexOf, + ArrayPrototypeIncludes, ArrayPrototypeMap, ArrayPrototypePush, ArrayPrototypeShift, @@ -570,6 +567,12 @@ function bootstrapMainRuntime(runtimeOptions) { } } + if (!ArrayPrototypeIncludes(unstableFeatures, /* unsafe-proto */ 9)) { + // Removes the `__proto__` for security reasons. + // https://tc39.es/ecma262/#sec-get-object.prototype.__proto__ + delete Object.prototype.__proto__; + } + // Setup `Deno` global - we're actually overriding already existing global // `Deno` with `Deno` namespace from "./deno.ts". ObjectDefineProperty(globalThis, "Deno", util.readOnly(finalDenoNs)); @@ -668,6 +671,13 @@ function bootstrapWorkerRuntime( ObjectAssign(finalDenoNs, denoNsUnstableById[id]); } } + + if (!ArrayPrototypeIncludes(unstableFeatures, /* unsafe-proto */ 9)) { + // Removes the `__proto__` for security reasons. + // https://tc39.es/ecma262/#sec-get-object.prototype.__proto__ + delete Object.prototype.__proto__; + } + ObjectDefineProperties(finalDenoNs, { pid: util.getterOnly(opPid), noColor: util.getterOnly(() => ops.op_bootstrap_no_color()), |