From f7ea75fd0ab11ebc2a07cfe12efb476e3f63775b Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 21 Feb 2022 12:32:49 +0100 Subject: [PATCH] lib: add legacy built-in functions to primordials PR-URL: https://github.com/nodejs/node/pull/42049 Reviewed-By: Darshan Sen Reviewed-By: Mestery --- lib/.eslintrc.yaml | 3 +++ lib/internal/freeze_intrinsics.js | 3 +++ lib/internal/per_context/primordials.js | 9 +++++++++ 3 files changed, 15 insertions(+) diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 83d6855a1cc0a0..af60e4139a4195 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -138,6 +138,8 @@ rules: - name: decodeURIComponent - name: encodeURI - name: encodeURIComponent + - name: escape + - name: eval - name: Error ignore: - prepareStackTrace @@ -181,6 +183,7 @@ rules: - name: Uint32Array - name: Uint8Array - name: Uint8ClampedArray + - name: unescape - name: URIError - name: WeakMap into: Safe diff --git a/lib/internal/freeze_intrinsics.js b/lib/internal/freeze_intrinsics.js index 82720f0ef95aba..0dcfea1ef2ec28 100644 --- a/lib/internal/freeze_intrinsics.js +++ b/lib/internal/freeze_intrinsics.js @@ -121,7 +121,9 @@ const { decodeURIComponent, encodeURI, encodeURIComponent, + escape, globalThis, + unescape, } = primordials; const { @@ -232,6 +234,7 @@ module.exports = function() { // 19 The Global Object // 19.2 Function Properties of the Global Object + // eslint-disable-next-line node-core/prefer-primordials eval, // eslint-disable-next-line node-core/prefer-primordials isFinite, diff --git a/lib/internal/per_context/primordials.js b/lib/internal/per_context/primordials.js index 2c0df17fbe1170..7d9368e678cc96 100644 --- a/lib/internal/per_context/primordials.js +++ b/lib/internal/per_context/primordials.js @@ -154,6 +154,15 @@ function copyPrototype(src, dest, prefix) { primordials[fn.name] = fn; }); +// Create copies of legacy functions +[ + escape, + eval, + unescape, +].forEach((fn) => { + primordials[fn.name] = fn; +}); + // Create copies of the namespace objects [ 'JSON',