mirror of https://github.com/gorhill/uBlock.git
Log all by default when needle is empty in `aost` scriptlet
As discussed with filter list maintainers.
This commit is contained in:
parent
42f31b9d16
commit
fddca0b7cb
|
@ -87,7 +87,6 @@ function safeSelf() {
|
||||||
const match = /^\/(.+)\/([gimsu]*)$/.exec(pattern);
|
const match = /^\/(.+)\/([gimsu]*)$/.exec(pattern);
|
||||||
if ( match !== null ) {
|
if ( match !== null ) {
|
||||||
return {
|
return {
|
||||||
pattern,
|
|
||||||
re: new this.RegExp(
|
re: new this.RegExp(
|
||||||
match[1],
|
match[1],
|
||||||
match[2] || options.flags
|
match[2] || options.flags
|
||||||
|
@ -95,18 +94,23 @@ function safeSelf() {
|
||||||
expect,
|
expect,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
if ( options.flags !== undefined ) {
|
||||||
pattern,
|
return {
|
||||||
re: new this.RegExp(pattern.replace(
|
re: new this.RegExp(pattern.replace(
|
||||||
/[.*+?^${}()|[\]\\]/g, '\\$&'),
|
/[.*+?^${}()|[\]\\]/g, '\\$&'),
|
||||||
options.flags
|
options.flags
|
||||||
),
|
),
|
||||||
expect,
|
expect,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
return { pattern, expect };
|
||||||
},
|
},
|
||||||
testPattern(details, haystack) {
|
testPattern(details, haystack) {
|
||||||
if ( details.matchAll ) { return true; }
|
if ( details.matchAll ) { return true; }
|
||||||
return this.RegExp_test.call(details.re, haystack) === details.expect;
|
if ( details.re ) {
|
||||||
|
return this.RegExp_test.call(details.re, haystack) === details.expect;
|
||||||
|
}
|
||||||
|
return haystack.includes(details.pattern) === details.expect;
|
||||||
},
|
},
|
||||||
patternToRegex(pattern, flags = undefined, verbatim = false) {
|
patternToRegex(pattern, flags = undefined, verbatim = false) {
|
||||||
if ( pattern === '' ) { return /^/; }
|
if ( pattern === '' ) { return /^/; }
|
||||||
|
@ -958,7 +962,7 @@ builtinScriptlets.push({
|
||||||
});
|
});
|
||||||
function matchesStackTrace(
|
function matchesStackTrace(
|
||||||
needleDetails,
|
needleDetails,
|
||||||
logLevel = 0
|
logLevel = ''
|
||||||
) {
|
) {
|
||||||
const safe = safeSelf();
|
const safe = safeSelf();
|
||||||
const exceptionToken = getExceptionToken();
|
const exceptionToken = getExceptionToken();
|
||||||
|
@ -989,11 +993,12 @@ function matchesStackTrace(
|
||||||
}
|
}
|
||||||
lines[0] = `stackDepth:${lines.length-1}`;
|
lines[0] = `stackDepth:${lines.length-1}`;
|
||||||
const stack = lines.join('\t');
|
const stack = lines.join('\t');
|
||||||
const r = safe.testPattern(needleDetails, stack);
|
const r = needleDetails.matchAll !== true &&
|
||||||
|
safe.testPattern(needleDetails, stack);
|
||||||
if (
|
if (
|
||||||
logLevel === 1 ||
|
logLevel === 'all' ||
|
||||||
logLevel === 2 && r ||
|
logLevel === 'match' && r ||
|
||||||
logLevel === 3 && !r
|
logLevel === 'nomatch' && !r
|
||||||
) {
|
) {
|
||||||
safe.uboLog(stack.replace(/\t/g, '\n'));
|
safe.uboLog(stack.replace(/\t/g, '\n'));
|
||||||
}
|
}
|
||||||
|
@ -1391,6 +1396,7 @@ function abortOnStackTrace(
|
||||||
const safe = safeSelf();
|
const safe = safeSelf();
|
||||||
const needleDetails = safe.initPattern(needle, { canNegate: true });
|
const needleDetails = safe.initPattern(needle, { canNegate: true });
|
||||||
const extraArgs = safe.getExtraArgs(Array.from(arguments), 2);
|
const extraArgs = safe.getExtraArgs(Array.from(arguments), 2);
|
||||||
|
if ( needle === '' ) { extraArgs.log = 'all'; }
|
||||||
const makeProxy = function(owner, chain) {
|
const makeProxy = function(owner, chain) {
|
||||||
const pos = chain.indexOf('.');
|
const pos = chain.indexOf('.');
|
||||||
if ( pos === -1 ) {
|
if ( pos === -1 ) {
|
||||||
|
|
Loading…
Reference in New Issue