From 0476d355995bacd96a1d2c72a39145148feb5b6c Mon Sep 17 00:00:00 2001 From: Chrissi2812 Date: Wed, 29 May 2019 11:21:40 +0200 Subject: [PATCH] fix infinite loop on some RegExp --- packages/tiptap-extensions/src/extensions/Search.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/tiptap-extensions/src/extensions/Search.js b/packages/tiptap-extensions/src/extensions/Search.js index 0ccbb9e38..95e4fc9cd 100644 --- a/packages/tiptap-extensions/src/extensions/Search.js +++ b/packages/tiptap-extensions/src/extensions/Search.js @@ -67,8 +67,6 @@ export default class Search extends Extension { return } - const search = this.findRegExp - doc.descendants((node, pos) => { if (node.isText) { if (mergedTextNodes[index]) { @@ -88,8 +86,12 @@ export default class Search extends Extension { }) mergedTextNodes.forEach(({ text, pos }) => { + const search = this.findRegExp let m while (m = search.exec(text)) { + if (m[0] === '') { + break + } this.results.push({ from: pos + m.index, to: pos + m.index + m[0].length,