fix infinite loop on some RegExp

This commit is contained in:
Chrissi2812 2019-05-29 11:21:40 +02:00
parent 87995cb93c
commit 0476d35599
No known key found for this signature in database
GPG Key ID: B4B82C7E618271DA

View File

@ -67,8 +67,6 @@ export default class Search extends Extension {
return return
} }
const search = this.findRegExp
doc.descendants((node, pos) => { doc.descendants((node, pos) => {
if (node.isText) { if (node.isText) {
if (mergedTextNodes[index]) { if (mergedTextNodes[index]) {
@ -88,8 +86,12 @@ export default class Search extends Extension {
}) })
mergedTextNodes.forEach(({ text, pos }) => { mergedTextNodes.forEach(({ text, pos }) => {
const search = this.findRegExp
let m let m
while (m = search.exec(text)) { while (m = search.exec(text)) {
if (m[0] === '') {
break
}
this.results.push({ this.results.push({
from: pos + m.index, from: pos + m.index,
to: pos + m.index + m[0].length, to: pos + m.index + m[0].length,