From b480184fd66a3e509d6a3556ce12d6373d421d66 Mon Sep 17 00:00:00 2001 From: Tim Caswell Date: Fri, 28 May 2010 14:48:37 -0700 Subject: [PATCH] Check for a couple of edge cases on the inspect hook. Don't treat sys.inspect special, same with prototype objects. --- lib/sys.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/sys.js b/lib/sys.js index 7aba932205b..28ec6ff740e 100644 --- a/lib/sys.js +++ b/lib/sys.js @@ -33,7 +33,12 @@ exports.inspect = function (obj, showHidden, depth) { var seen = []; function format(value, recurseTimes) { // Provide a hook for user-specified inspect functions. - if (value && typeof value.inspect === 'function') { + // Check that value is an object with an inspect function on it + if (value && typeof value.inspect === 'function' && + // Filter out the sys module, it's inspect function is special + value !== exports && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { return value.inspect(recurseTimes); }