Log all by default when needle is empty in aost scriptlet

As discussed with filter list maintainers.
This commit is contained in:
Raymond Hill 2023-12-06 10:17:19 -05:00
parent 42f31b9d16
commit fddca0b7cb
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -87,7 +87,6 @@ function safeSelf() {
const match = /^\/(.+)\/([gimsu]*)$/.exec(pattern);
if ( match !== null ) {
return {
pattern,
re: new this.RegExp(
match[1],
match[2] || options.flags
@ -95,18 +94,23 @@ function safeSelf() {
expect,
};
}
return {
pattern,
re: new this.RegExp(pattern.replace(
/[.*+?^${}()|[\]\\]/g, '\\$&'),
options.flags
),
expect,
};
if ( options.flags !== undefined ) {
return {
re: new this.RegExp(pattern.replace(
/[.*+?^${}()|[\]\\]/g, '\\$&'),
options.flags
),
expect,
};
}
return { pattern, expect };
},
testPattern(details, haystack) {
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) {
if ( pattern === '' ) { return /^/; }
@ -958,7 +962,7 @@ builtinScriptlets.push({
});
function matchesStackTrace(
needleDetails,
logLevel = 0
logLevel = ''
) {
const safe = safeSelf();
const exceptionToken = getExceptionToken();
@ -989,11 +993,12 @@ function matchesStackTrace(
}
lines[0] = `stackDepth:${lines.length-1}`;
const stack = lines.join('\t');
const r = safe.testPattern(needleDetails, stack);
const r = needleDetails.matchAll !== true &&
safe.testPattern(needleDetails, stack);
if (
logLevel === 1 ||
logLevel === 2 && r ||
logLevel === 3 && !r
logLevel === 'all' ||
logLevel === 'match' && r ||
logLevel === 'nomatch' && !r
) {
safe.uboLog(stack.replace(/\t/g, '\n'));
}
@ -1391,6 +1396,7 @@ function abortOnStackTrace(
const safe = safeSelf();
const needleDetails = safe.initPattern(needle, { canNegate: true });
const extraArgs = safe.getExtraArgs(Array.from(arguments), 2);
if ( needle === '' ) { extraArgs.log = 'all'; }
const makeProxy = function(owner, chain) {
const pos = chain.indexOf('.');
if ( pos === -1 ) {