util: ensure that the .inspect function isn't the one being executed
Fixes #2225.
This commit is contained in:
parent
754e23db27
commit
b204006105
@ -155,7 +155,7 @@ function formatValue(ctx, value, recurseTimes) {
|
|||||||
// Check that value is an object with an inspect function on it
|
// Check that value is an object with an inspect function on it
|
||||||
if (value && typeof value.inspect === 'function' &&
|
if (value && typeof value.inspect === 'function' &&
|
||||||
// Filter out the util module, it's inspect function is special
|
// Filter out the util module, it's inspect function is special
|
||||||
value !== exports &&
|
value.inspect !== exports.inspect &&
|
||||||
// Also filter out any prototype objects using the circular check.
|
// Also filter out any prototype objects using the circular check.
|
||||||
!(value.constructor && value.constructor.prototype === value)) {
|
!(value.constructor && value.constructor.prototype === value)) {
|
||||||
return value.inspect(recurseTimes);
|
return value.inspect(recurseTimes);
|
||||||
|
@ -75,3 +75,7 @@ assert.doesNotThrow(function () {
|
|||||||
r.toString = null;
|
r.toString = null;
|
||||||
util.inspect(r);
|
util.inspect(r);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// GH-2225
|
||||||
|
var x = { inspect: util.inspect };
|
||||||
|
assert.ok(util.inspect(x).indexOf('inspect') != -1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user