From f3e63ea32c795474a9c92d38b06188d54fd92be3 Mon Sep 17 00:00:00 2001 From: Nemanja Stojanovic Date: Tue, 28 Feb 2017 13:58:56 -0500 Subject: [PATCH] util: convert inspect.styles and inspect.colors to prototype-less objects Use a prototype-less object for inspect.styles and inspect.colors to allow modification of Object.prototype in the REPL. Fixes: https://github.com/nodejs/node/issues/11614 --- lib/util.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/util.js b/lib/util.js index 6453727ad843b0..08e147e3042144 100644 --- a/lib/util.js +++ b/lib/util.js @@ -166,7 +166,7 @@ Object.defineProperty(inspect, 'defaultOptions', { }); // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics -inspect.colors = { +inspect.colors = Object.assign(Object.create(null), { 'bold': [1, 22], 'italic': [3, 23], 'underline': [4, 24], @@ -180,10 +180,10 @@ inspect.colors = { 'magenta': [35, 39], 'red': [31, 39], 'yellow': [33, 39] -}; +}); // Don't use 'blue' not visible on cmd.exe -inspect.styles = { +inspect.styles = Object.assign(Object.create(null), { 'special': 'cyan', 'number': 'yellow', 'boolean': 'yellow', @@ -194,7 +194,7 @@ inspect.styles = { 'date': 'magenta', // "name": intentionally not styling 'regexp': 'red' -}; +}); const customInspectSymbol = internalUtil.customInspectSymbol;