Skip to content

Commit aab0d20

Browse files
Nemanja Stojanovicjasnell
Nemanja Stojanovic
authored andcommitted
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: #11614 PR-URL: #11624 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Timothy Gu <[email protected]>
1 parent fd17e8b commit aab0d20

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/util.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Object.defineProperty(inspect, 'defaultOptions', {
166166
});
167167

168168
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
169-
inspect.colors = {
169+
inspect.colors = Object.assign(Object.create(null), {
170170
'bold': [1, 22],
171171
'italic': [3, 23],
172172
'underline': [4, 24],
@@ -180,10 +180,10 @@ inspect.colors = {
180180
'magenta': [35, 39],
181181
'red': [31, 39],
182182
'yellow': [33, 39]
183-
};
183+
});
184184

185185
// Don't use 'blue' not visible on cmd.exe
186-
inspect.styles = {
186+
inspect.styles = Object.assign(Object.create(null), {
187187
'special': 'cyan',
188188
'number': 'yellow',
189189
'boolean': 'yellow',
@@ -194,7 +194,7 @@ inspect.styles = {
194194
'date': 'magenta',
195195
// "name": intentionally not styling
196196
'regexp': 'red'
197-
};
197+
});
198198

199199
const customInspectSymbol = internalUtil.customInspectSymbol;
200200

0 commit comments

Comments
 (0)