From c350e23b2d832c76901612a2b6669163245cfe02 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 29 Jun 2023 09:05:48 -0400 Subject: [PATCH] Fix regression in parameters-passing in scriptlets --- src/js/scriptlet-filtering.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/js/scriptlet-filtering.js b/src/js/scriptlet-filtering.js index 951bedc64..d1441cc66 100644 --- a/src/js/scriptlet-filtering.js +++ b/src/js/scriptlet-filtering.js @@ -41,6 +41,7 @@ const VERSION = 1; const duplicates = new Set(); const scriptletCache = new µb.MRUCache(32); +const reEscapeScriptArg = /[\\'"]/g; const scriptletDB = new StaticExtFilteringHostnameDB(1, VERSION); @@ -217,7 +218,9 @@ const patchScriptlet = function(content, arglist) { content = content.replace(`{{${i+1}}}`, arglist[i]); } return content.replace('{{args}}', - arglist.map(a => `'${a}'`).join(', ').replace(/\$/g, '$$$') + arglist.map(a => `'${a.replace(reEscapeScriptArg, '\\$&')}'`) + .join(', ') + .replace(/\$/g, '$$$') ); };