mirror of https://github.com/gorhill/uBlock.git
Add support for AdGuard's noop (`_`) network filter option
Reference: - https://adguard.com/kb/general/ad-filtering/create-own-filters/#noop-modifier uBO already supported the noop filter option `_` to allow filter authors to resolve possible ambiguities arising when crafting network filters with many options. AdGuard extended the semantic of the `_` option to also resolve readability issues by supporting multiple instances of the `_` option in a single filter, and also by supporting any number of consecutive `_` in a single noop filter option.
This commit is contained in:
parent
b44815f0c8
commit
33b409dd5b
|
@ -798,6 +798,7 @@ export class AstFilterParser {
|
||||||
this.reUnescapeCommas = /((?:^|[^\\])(?:\\\\)*)\\,/g;
|
this.reUnescapeCommas = /((?:^|[^\\])(?:\\\\)*)\\,/g;
|
||||||
this.reUnescapeSingleQuotes = /((?:^|[^\\])(?:\\\\)*)\\'/g;
|
this.reUnescapeSingleQuotes = /((?:^|[^\\])(?:\\\\)*)\\'/g;
|
||||||
this.reUnescapeDoubleQuotes = /((?:^|[^\\])(?:\\\\)*)\\"/g;
|
this.reUnescapeDoubleQuotes = /((?:^|[^\\])(?:\\\\)*)\\"/g;
|
||||||
|
this.reNoopOption = /^_+$/;
|
||||||
}
|
}
|
||||||
|
|
||||||
parse(raw) {
|
parse(raw) {
|
||||||
|
@ -1854,13 +1855,21 @@ export class AstFilterParser {
|
||||||
const equalPos = s.indexOf('=');
|
const equalPos = s.indexOf('=');
|
||||||
const nameEnd = equalPos !== -1 ? equalPos : s.length;
|
const nameEnd = equalPos !== -1 ? equalPos : s.length;
|
||||||
const name = s.slice(nameBeg, nameEnd);
|
const name = s.slice(nameBeg, nameEnd);
|
||||||
const nodeOptionType = nodeTypeFromOptionName.get(name) || NODE_TYPE_NET_OPTION_NAME_UNKNOWN;
|
let nodeOptionType = nodeTypeFromOptionName.get(name);
|
||||||
|
if ( nodeOptionType === undefined ) {
|
||||||
|
nodeOptionType = this.reNoopOption.test(name)
|
||||||
|
? NODE_TYPE_NET_OPTION_NAME_NOOP
|
||||||
|
: NODE_TYPE_NET_OPTION_NAME_UNKNOWN;
|
||||||
|
}
|
||||||
next = this.allocTypedNode(
|
next = this.allocTypedNode(
|
||||||
nodeOptionType,
|
nodeOptionType,
|
||||||
parentBeg + nameBeg,
|
parentBeg + nameBeg,
|
||||||
parentBeg + nameEnd
|
parentBeg + nameEnd
|
||||||
);
|
);
|
||||||
if ( this.getBranchFromType(nodeOptionType) !== 0 ) {
|
if (
|
||||||
|
nodeOptionType !== NODE_TYPE_NET_OPTION_NAME_NOOP &&
|
||||||
|
this.getBranchFromType(nodeOptionType) !== 0
|
||||||
|
) {
|
||||||
this.addNodeFlags(parent, NODE_FLAG_ERROR);
|
this.addNodeFlags(parent, NODE_FLAG_ERROR);
|
||||||
this.addFlags(AST_FLAG_HAS_ERROR);
|
this.addFlags(AST_FLAG_HAS_ERROR);
|
||||||
this.astError = AST_ERROR_OPTION_DUPLICATE;
|
this.astError = AST_ERROR_OPTION_DUPLICATE;
|
||||||
|
|
Loading…
Reference in New Issue