1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-02 00:42:45 +01:00

Fix regression in parameters-passing in scriptlets

This commit is contained in:
Raymond Hill 2023-06-29 09:05:48 -04:00
parent 8e010f9c87
commit c350e23b2d
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -41,6 +41,7 @@ const VERSION = 1;
const duplicates = new Set(); const duplicates = new Set();
const scriptletCache = new µb.MRUCache(32); const scriptletCache = new µb.MRUCache(32);
const reEscapeScriptArg = /[\\'"]/g;
const scriptletDB = new StaticExtFilteringHostnameDB(1, VERSION); const scriptletDB = new StaticExtFilteringHostnameDB(1, VERSION);
@ -217,7 +218,9 @@ const patchScriptlet = function(content, arglist) {
content = content.replace(`{{${i+1}}}`, arglist[i]); content = content.replace(`{{${i+1}}}`, arglist[i]);
} }
return content.replace('{{args}}', return content.replace('{{args}}',
arglist.map(a => `'${a}'`).join(', ').replace(/\$/g, '$$$') arglist.map(a => `'${a.replace(reEscapeScriptArg, '\\$&')}'`)
.join(', ')
.replace(/\$/g, '$$$')
); );
}; };