1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-19 03:05:22 +02:00
Raymond Hill 2023-05-30 08:38:35 -04:00
parent 996bf0925d
commit 56e1d92dbd
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -1049,23 +1049,11 @@ function evaldataPrune(
) { ) {
self.eval = new Proxy(self.eval, { self.eval = new Proxy(self.eval, {
apply(target, thisArg, args) { apply(target, thisArg, args) {
let dataToEval = `${args[0]}`; let data = Reflect.apply(target, thisArg, args);
const match = /^\s*\(\s*(\{.+\})\s*\)\s*$/s.exec(dataToEval);
if ( match !== null ) {
dataToEval = match[1];
}
let data;
try {
data = JSON.parse(dataToEval);
if ( typeof data === 'object' ) { if ( typeof data === 'object' ) {
let after = JSON.stringify( data = objectPrune(data, rawPrunePaths, rawNeedlePaths);
objectPrune(data, rawPrunePaths, rawNeedlePaths)
);
args[0] = `(${after})`;
} }
} catch(ex) { return data;
}
return Reflect.apply(target, thisArg, args);
} }
}); });
} }
@ -2332,7 +2320,7 @@ function hrefSanitizer(
}; };
const extractText = (elem, source) => { const extractText = (elem, source) => {
if ( /^\[.*\]$/.test(source) ) { if ( /^\[.*\]$/.test(source) ) {
return elem.getAttribute(source.slice(1,-1).trim()) || ''; source = elem.getAttribute(source.slice(1,-1).trim()) || '';
} }
if ( source !== 'text' ) { return ''; } if ( source !== 'text' ) { return ''; }
const text = elem.textContent const text = elem.textContent