Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

Fixes #2225.
  • Loading branch information...
commit 05860efa5cd6e776f5f800d38105c1b0702faecc 1 parent b159c6d
Nathan Rajlich authored

Showing 2 changed files with 5 additions and 1 deletion. Show diff stats Hide diff stats

  1. +1 1  lib/util.js
  2. +4 0 test/simple/test-util-inspect.js
2  lib/util.js
@@ -155,7 +155,7 @@ function formatValue(ctx, value, recurseTimes) {
155 155 // Check that value is an object with an inspect function on it
156 156 if (value && typeof value.inspect === 'function' &&
157 157 // Filter out the util module, it's inspect function is special
158   - value !== exports &&
  158 + value.inspect !== exports.inspect &&
159 159 // Also filter out any prototype objects using the circular check.
160 160 !(value.constructor && value.constructor.prototype === value)) {
161 161 return value.inspect(recurseTimes);
4 test/simple/test-util-inspect.js
@@ -75,3 +75,7 @@ assert.doesNotThrow(function () {
75 75 r.toString = null;
76 76 util.inspect(r);
77 77 });
  78 +
  79 +// GH-2225
  80 +var x = { inspect: util.inspect };
  81 +assert.ok(util.inspect(x).indexOf('inspect') != -1);

0 comments on commit 05860ef

Please sign in to comment.
Something went wrong with that request. Please try again.