From 5be84a5d59e9bc0b206e5520530445d0cfc5c94e Mon Sep 17 00:00:00 2001 From: aurimasv Date: Mon, 12 Mar 2012 20:33:59 -0500 Subject: [PATCH] add maxLevels to varDump to avoid infinite loops --- chrome/content/zotero/xpcom/utilities.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index 81e72d60b..bdf52ace7 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -1014,17 +1014,25 @@ Zotero.Utilities = { * * Adapted from http://binnyva.blogspot.com/2005/10/dump-function-javascript-equivalent-of.html */ - "varDump":function(arr,level) { + "varDump":function(arr,level,maxLevel) { var dumped_text = ""; if (!level){ level = 0; } + + if (!maxLevel) { + maxLevel = 4; + } // The padding given at the beginning of the line. var level_padding = ""; for (var j=0;j maxLevel){ + return dumped_text + level_padding + "...\n"; + } if (typeof(arr) == 'object') { // Array/Hashes/Objects for (var item in arr) { @@ -1032,7 +1040,7 @@ Zotero.Utilities = { if (typeof(value) == 'object') { // If it is an array, dumped_text += level_padding + "'" + item + "' ...\n"; - dumped_text += arguments.callee(value,level+1); + dumped_text += arguments.callee(value,level+1,maxLevel); } else { if (typeof value == 'function'){