Skip to content

Commit

Permalink
Reset g regexes before use in rmnt/rpnt scriptlets
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Nov 6, 2023
1 parent bf001f4 commit cdc3f66
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion assets/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,11 @@ function replaceNodeTextFn(
let sedCount = extraArgs.sedCount || 0;
const handleNode = node => {
const before = node.textContent;
if ( safe.RegExp_test.call(rePattern, before) === false ) { return true; }
reCondition.lastIndex = 0;
if ( safe.RegExp_test.call(reCondition, before) === false ) { return true; }
rePattern.lastIndex = 0;
if ( safe.RegExp_test.call(rePattern, before) === false ) { return true; }
rePattern.lastIndex = 0;
const after = pattern !== ''
? before.replace(rePattern, replacement)
: replacement;
Expand Down

0 comments on commit cdc3f66

Please sign in to comment.