mirror of https://github.com/gorhill/uBlock.git
Fix decompiling of scriptlet parameters
Scriptlets parameters which are quoted must be re-quoted when output to the logger to be sure they can be properly looked up in the list, and that they can be used through copy-paste operations.
This commit is contained in:
parent
12b9efe74b
commit
fa3a290ad4
|
@ -99,7 +99,21 @@ const patchScriptlet = (content, arglist) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const decompile = json => {
|
const decompile = json => {
|
||||||
const args = JSON.parse(json).map(s => s.replace(/,/g, '\\,'));
|
const args = JSON.parse(json).map(s => {
|
||||||
|
if ( /^(["'`]).+\1$/.test(s) ) {
|
||||||
|
const c0 = s.charAt(0);
|
||||||
|
const inner = s.slice(1,-1);
|
||||||
|
if ( c0 === '"' || c0 === '`' ) {
|
||||||
|
return inner.includes("'")
|
||||||
|
? '`' + s.replace(/`/g, '\\`') + '`'
|
||||||
|
: `'${s}'`;
|
||||||
|
}
|
||||||
|
return inner.includes('"')
|
||||||
|
? '`' + s.replace(/`/g, '\\`') + '`'
|
||||||
|
: `"${s}"`;
|
||||||
|
}
|
||||||
|
return s.replace(/,/g, '\\,');
|
||||||
|
});
|
||||||
if ( args.length === 0 ) { return '+js()'; }
|
if ( args.length === 0 ) { return '+js()'; }
|
||||||
return `+js(${args.join(', ')})`;
|
return `+js(${args.join(', ')})`;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue