Skip to content

Commit

Permalink
Fix page crash when using invalid regex flags
Browse files Browse the repository at this point in the history
  • Loading branch information
lmg-anon authored Sep 29, 2024
1 parent 3933223 commit 7c6a886
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mikupad.html
Original file line number Diff line number Diff line change
Expand Up @@ -3738,7 +3738,7 @@

function findAllMatches(mode, search, flags, elem) {
if (!inputElement)
return 0
return [];
setSearchAndReplaceError(undefined)
let startIndex = 0;
let index;
Expand Down Expand Up @@ -3768,9 +3768,9 @@
}
catch (e) {
reportError(e);
const errStr = e.toString()
setSearchAndReplaceError(errStr)
return null
const errStr = e.toString();
setSearchAndReplaceError(errStr);
return [];
}
}
return positions;
Expand Down Expand Up @@ -3815,7 +3815,7 @@
function findAndStorePositions(mode,search,flags,elem) {
positions.current = findAllMatches(mode, search, flags, elem);
setCurrentIndex(-1);
if (positions.current.length === 0)
if (!searchAndReplaceError && positions.current.length === 0)
setSearchAndReplaceError(`Warning: No matches found for ${ (mode==0?"Plaintext":mode==1?"RegEx":"Template") } \'${search}\'`)
}

Expand All @@ -3826,7 +3826,7 @@
if (!search)
return
positions.current = findAllMatches(mode, search, flags, inputElement);
if (positions.current.length === 0) {
if (!searchAndReplaceError && positions.current.length === 0) {
setSearchAndReplaceError(`Warning: No matches found for ${ (mode==0?"Plaintext":mode==1?"RegEx":"Template") } \'${search}\'`)
return
}
Expand Down

0 comments on commit 7c6a886

Please sign in to comment.