From 568259d8976e23da5d705cd24a35eef88255a259 Mon Sep 17 00:00:00 2001 From: patsul12 Date: Fri, 1 Jan 2016 14:31:07 -0800 Subject: [PATCH] add a check for single line, multi-line formatted comments, to prevent loop protect from triggering in these instances --- public/js/lib/loop-protect/loop-protect.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/js/lib/loop-protect/loop-protect.js b/public/js/lib/loop-protect/loop-protect.js index 341fb6fa5f..ac3376b6e1 100644 --- a/public/js/lib/loop-protect/loop-protect.js +++ b/public/js/lib/loop-protect/loop-protect.js @@ -50,7 +50,6 @@ if (typeof DEBUG === 'undefined') { DEBUG = true; } var openPos = -1; do { - j -= 1; DEBUG && debug('looking backwards ' + lines[j]); // jshint ignore:line closePos = lines[j].indexOf('*/'); openPos = lines[j].indexOf('/*'); @@ -59,6 +58,11 @@ if (typeof DEBUG === 'undefined') { DEBUG = true; } closeCommentTags++; } + // check for single line /* comment */ formatted comments + if (closePos === lines[j].length - 2 && openPos !== -1) { + closeCommentTags--; + } + if (openPos !== -1) { closeCommentTags--; @@ -67,6 +71,7 @@ if (typeof DEBUG === 'undefined') { DEBUG = true; } return true; } } + j -= 1; } while (j !== 0); return false;