Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! util: protect against monkeypatched Object prototype for inspe…
…ct()
  • Loading branch information
Trott committed Feb 8, 2019
commit 474811203374e63e6f195324cf8dfb0eb35b9c84
10 changes: 6 additions & 4 deletions lib/internal/util/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ function uncurryThis(func) {
return (thisArg, ...args) => ReflectApply(func, thisArg, args);
}

const propertyIsEnumerable = uncurryThis(Object.prototype.propertyIsEnumerable);
const propertyIsEnumerable = uncurryThis(
primordials.Object.prototype.propertyIsEnumerable
);
const regExpToString = uncurryThis(RegExp.prototype.toString);
const dateToISOString = uncurryThis(Date.prototype.toISOString);
const dateToString = uncurryThis(Date.prototype.toString);
Expand All @@ -91,7 +93,7 @@ const stringValueOf = uncurryThis(String.prototype.valueOf);
const setValues = uncurryThis(Set.prototype.values);
const mapEntries = uncurryThis(Map.prototype.entries);
const dateGetTime = uncurryThis(Date.prototype.getTime);
const hasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty);
const hasOwnProperty = uncurryThis(primordials.Object.prototype.hasOwnProperty);
let hexSlice;

const inspectDefaultOptions = primordials.Object.seal({
Expand Down Expand Up @@ -229,7 +231,7 @@ inspect.colors = primordials.Object.assign(primordials.Object.create(null), {
});

// Don't use 'blue' not visible on cmd.exe
inspect.styles = primordials.Object.assign(Object.create(null), {
inspect.styles = primordials.Object.assign(primordials.Object.create(null), {
special: 'cyan',
number: 'yellow',
bigint: 'yellow',
Expand Down Expand Up @@ -807,7 +809,7 @@ function handleMaxCallStackSize(ctx, err, constructor, tag, indentationLvl) {

function formatNumber(fn, value) {
// Format -0 as '-0'. Checking `value === -0` won't distinguish 0 from -0.
return fn(Object.is(value, -0) ? '-0' : `${value}`, 'number');
return fn(primordials.Object.is(value, -0) ? '-0' : `${value}`, 'number');
}

function formatBigInt(fn, value) {
Expand Down