From cdc3f66a6b85a3135184132a776bd571192bd2fd Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 5 Nov 2023 20:34:11 -0500 Subject: [PATCH] Reset `g` regexes before use in `rmnt`/`rpnt` scriptlets --- assets/resources/scriptlets.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index 4d11aa7ab..476e88d55 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -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;