From 4328ea2c1f741e13b6db3167fc8fb82298544e84 Mon Sep 17 00:00:00 2001 From: mattpass Date: Fri, 9 Apr 2021 16:44:00 +0100 Subject: [PATCH] Add check on ^ $ and .* to avoid regex crash --- assets/js/icecoder.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/assets/js/icecoder.js b/assets/js/icecoder.js index b5f1b5a..21e6fe5 100644 --- a/assets/js/icecoder.js +++ b/assets/js/icecoder.js @@ -2831,6 +2831,15 @@ var ICEcoder = { findReplace: function(find, selectNext, canActionChanges, findPrevious) { let replace, results, thisCM, thisSelection, rBlocks, rExpMatch0String, replaceQS, targetQS, filesQS; + // Return early if we're finding with regex and only have ^ or $ or .*, avoids CPU crash + if (true === parent.ICEcoder.findRegex && "" === find.replace(/\^|\$|\.\*/g, "")) { + results.innerHTML = "No results"; + this.content.contentWindow.document.getElementById('resultsBar').innerHTML = ""; + this.content.contentWindow.document.getElementById('resultsBar').style.display = "none"; + + return false; + } + // Determine our find rExp, replace value and results display const rExp = new RegExp(true === parent.ICEcoder.findRegex ? find : ICEcoder.escapeRegex(find), "gi"); replace = get('replace').value;