Browse Source

util: ensure that the .inspect function isn't the one being executed

Fixes #2225.
v0.7.4-release
Nathan Rajlich 13 years ago
committed by Ben Noordhuis
parent
commit
b204006105
  1. 2
      lib/util.js
  2. 4
      test/simple/test-util-inspect.js

2
lib/util.js

@ -155,7 +155,7 @@ function formatValue(ctx, value, recurseTimes) {
// Check that value is an object with an inspect function on it
if (value && typeof value.inspect === 'function' &&
// 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.
!(value.constructor && value.constructor.prototype === value)) {
return value.inspect(recurseTimes);

4
test/simple/test-util-inspect.js

@ -75,3 +75,7 @@ assert.doesNotThrow(function () {
r.toString = null;
util.inspect(r);
});
// GH-2225
var x = { inspect: util.inspect };
assert.ok(util.inspect(x).indexOf('inspect') != -1);

Loading…
Cancel
Save