mirror of https://github.com/gorhill/uBlock.git
New network filter option: `to=[list of domain names]`
Related discussion: - https://github.com/uBlockOrigin/uBlock-issues/discussions/2412#discussioncomment-4421741 The new option is `to=` and the value is a list of domain list with similar syntax as `domain=` option. Entity-based syntax is supported, and also negated hostname. The main motivation is to give uBO's static network filtering engine with an equivalent of DNR's `requestDomains` and `excludedRequestDomains`. Essentially `to=` is a superset of `denyallow=`, but for now I decided against deprecating `denyallow=`, which still does not support entity- based syntax and for which negated domains are not allowed. This commit also introduces the `from=` option, which is just an alias for the `domain=` option. The logger will render network filters using the `from=` version.
This commit is contained in:
parent
84aa217ede
commit
19f8b30d57
|
@ -176,8 +176,8 @@ const µBlock = { // jshint ignore:line
|
||||||
|
|
||||||
// Read-only
|
// Read-only
|
||||||
systemSettings: {
|
systemSettings: {
|
||||||
compiledMagic: 51, // Increase when compiled format changes
|
compiledMagic: 52, // Increase when compiled format changes
|
||||||
selfieMagic: 51, // Increase when selfie format changes
|
selfieMagic: 52, // Increase when selfie format changes
|
||||||
},
|
},
|
||||||
|
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/759#issuecomment-546654501
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/759#issuecomment-546654501
|
||||||
|
|
|
@ -2348,11 +2348,11 @@ const OPTTokenCsp = 8;
|
||||||
const OPTTokenCss = 9;
|
const OPTTokenCss = 9;
|
||||||
const OPTTokenDenyAllow = 10;
|
const OPTTokenDenyAllow = 10;
|
||||||
const OPTTokenDoc = 11;
|
const OPTTokenDoc = 11;
|
||||||
const OPTTokenDomain = 12;
|
const OPTTokenEhide = 12;
|
||||||
const OPTTokenEhide = 13;
|
const OPTTokenEmpty = 13;
|
||||||
const OPTTokenEmpty = 14;
|
const OPTTokenFont = 14;
|
||||||
const OPTTokenFont = 15;
|
const OPTTokenFrame = 15;
|
||||||
const OPTTokenFrame = 16;
|
const OPTTokenFrom = 16;
|
||||||
const OPTTokenGenericblock = 17;
|
const OPTTokenGenericblock = 17;
|
||||||
const OPTTokenGhide = 18;
|
const OPTTokenGhide = 18;
|
||||||
const OPTTokenHeader = 19;
|
const OPTTokenHeader = 19;
|
||||||
|
@ -2374,11 +2374,12 @@ const OPTTokenRedirectRule = 34;
|
||||||
const OPTTokenRemoveparam = 35;
|
const OPTTokenRemoveparam = 35;
|
||||||
const OPTTokenScript = 36;
|
const OPTTokenScript = 36;
|
||||||
const OPTTokenShide = 37;
|
const OPTTokenShide = 37;
|
||||||
const OPTTokenXhr = 38;
|
const OPTTokenTo = 38;
|
||||||
const OPTTokenWebrtc = 39;
|
const OPTTokenXhr = 39;
|
||||||
const OPTTokenWebsocket = 40;
|
const OPTTokenWebrtc = 40;
|
||||||
const OPTTokenMethod = 41;
|
const OPTTokenWebsocket = 41;
|
||||||
const OPTTokenCount = 42;
|
const OPTTokenMethod = 42;
|
||||||
|
const OPTTokenCount = 43;
|
||||||
|
|
||||||
//const OPTPerOptionMask = 0x0000ff00;
|
//const OPTPerOptionMask = 0x0000ff00;
|
||||||
const OPTCanNegate = 1 << 8;
|
const OPTCanNegate = 1 << 8;
|
||||||
|
@ -2449,12 +2450,14 @@ Parser.prototype.OPTTokenAll = OPTTokenAll;
|
||||||
Parser.prototype.OPTTokenBadfilter = OPTTokenBadfilter;
|
Parser.prototype.OPTTokenBadfilter = OPTTokenBadfilter;
|
||||||
Parser.prototype.OPTTokenCname = OPTTokenCname;
|
Parser.prototype.OPTTokenCname = OPTTokenCname;
|
||||||
Parser.prototype.OPTTokenCsp = OPTTokenCsp;
|
Parser.prototype.OPTTokenCsp = OPTTokenCsp;
|
||||||
|
Parser.prototype.OPTTokenCss = OPTTokenCss;
|
||||||
Parser.prototype.OPTTokenDenyAllow = OPTTokenDenyAllow;
|
Parser.prototype.OPTTokenDenyAllow = OPTTokenDenyAllow;
|
||||||
Parser.prototype.OPTTokenDoc = OPTTokenDoc;
|
Parser.prototype.OPTTokenDoc = OPTTokenDoc;
|
||||||
Parser.prototype.OPTTokenDomain = OPTTokenDomain;
|
|
||||||
Parser.prototype.OPTTokenEhide = OPTTokenEhide;
|
Parser.prototype.OPTTokenEhide = OPTTokenEhide;
|
||||||
Parser.prototype.OPTTokenEmpty = OPTTokenEmpty;
|
Parser.prototype.OPTTokenEmpty = OPTTokenEmpty;
|
||||||
Parser.prototype.OPTTokenFont = OPTTokenFont;
|
Parser.prototype.OPTTokenFont = OPTTokenFont;
|
||||||
|
Parser.prototype.OPTTokenFrame = OPTTokenFrame;
|
||||||
|
Parser.prototype.OPTTokenFrom = OPTTokenFrom;
|
||||||
Parser.prototype.OPTTokenGenericblock = OPTTokenGenericblock;
|
Parser.prototype.OPTTokenGenericblock = OPTTokenGenericblock;
|
||||||
Parser.prototype.OPTTokenGhide = OPTTokenGhide;
|
Parser.prototype.OPTTokenGhide = OPTTokenGhide;
|
||||||
Parser.prototype.OPTTokenHeader = OPTTokenHeader;
|
Parser.prototype.OPTTokenHeader = OPTTokenHeader;
|
||||||
|
@ -2477,8 +2480,7 @@ Parser.prototype.OPTTokenRedirect = OPTTokenRedirect;
|
||||||
Parser.prototype.OPTTokenRedirectRule = OPTTokenRedirectRule;
|
Parser.prototype.OPTTokenRedirectRule = OPTTokenRedirectRule;
|
||||||
Parser.prototype.OPTTokenScript = OPTTokenScript;
|
Parser.prototype.OPTTokenScript = OPTTokenScript;
|
||||||
Parser.prototype.OPTTokenShide = OPTTokenShide;
|
Parser.prototype.OPTTokenShide = OPTTokenShide;
|
||||||
Parser.prototype.OPTTokenCss = OPTTokenCss;
|
Parser.prototype.OPTTokenTo = OPTTokenTo;
|
||||||
Parser.prototype.OPTTokenFrame = OPTTokenFrame;
|
|
||||||
Parser.prototype.OPTTokenXhr = OPTTokenXhr;
|
Parser.prototype.OPTTokenXhr = OPTTokenXhr;
|
||||||
Parser.prototype.OPTTokenWebrtc = OPTTokenWebrtc;
|
Parser.prototype.OPTTokenWebrtc = OPTTokenWebrtc;
|
||||||
Parser.prototype.OPTTokenWebsocket = OPTTokenWebsocket;
|
Parser.prototype.OPTTokenWebsocket = OPTTokenWebsocket;
|
||||||
|
@ -2512,12 +2514,13 @@ const netOptionTokenDescriptors = new Map([
|
||||||
[ 'denyallow', OPTTokenDenyAllow | OPTMustAssign | OPTDomainList | OPTNeedDomainOpt | OPTNonCspableType ],
|
[ 'denyallow', OPTTokenDenyAllow | OPTMustAssign | OPTDomainList | OPTNeedDomainOpt | OPTNonCspableType ],
|
||||||
[ 'doc', OPTTokenDoc | OPTNetworkType | OPTCanNegate | OPTModifiableType | OPTRedirectableType ],
|
[ 'doc', OPTTokenDoc | OPTNetworkType | OPTCanNegate | OPTModifiableType | OPTRedirectableType ],
|
||||||
/* synonym */ [ 'document', OPTTokenDoc | OPTNetworkType | OPTCanNegate | OPTModifiableType | OPTRedirectableType ],
|
/* synonym */ [ 'document', OPTTokenDoc | OPTNetworkType | OPTCanNegate | OPTModifiableType | OPTRedirectableType ],
|
||||||
[ 'domain', OPTTokenDomain | OPTMustAssign | OPTDomainList ],
|
|
||||||
[ 'ehide', OPTTokenEhide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
[ 'ehide', OPTTokenEhide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
/* synonym */ [ 'elemhide', OPTTokenEhide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
/* synonym */ [ 'elemhide', OPTTokenEhide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
[ 'empty', OPTTokenEmpty | OPTBlockOnly | OPTModifierType ],
|
[ 'empty', OPTTokenEmpty | OPTBlockOnly | OPTModifierType ],
|
||||||
[ 'frame', OPTTokenFrame | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType ],
|
[ 'frame', OPTTokenFrame | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType ],
|
||||||
/* synonym */ [ 'subdocument', OPTTokenFrame | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType ],
|
/* synonym */ [ 'subdocument', OPTTokenFrame | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType ],
|
||||||
|
[ 'from', OPTTokenFrom | OPTMustAssign | OPTDomainList ],
|
||||||
|
/* synonym */ [ 'domain', OPTTokenFrom | OPTMustAssign | OPTDomainList ],
|
||||||
[ 'font', OPTTokenFont | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTNonCspableType ],
|
[ 'font', OPTTokenFont | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTNonCspableType ],
|
||||||
[ 'genericblock', OPTTokenGenericblock | OPTNotSupported ],
|
[ 'genericblock', OPTTokenGenericblock | OPTNotSupported ],
|
||||||
[ 'ghide', OPTTokenGhide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
[ 'ghide', OPTTokenGhide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
|
@ -2547,6 +2550,7 @@ const netOptionTokenDescriptors = new Map([
|
||||||
[ 'script', OPTTokenScript | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
[ 'script', OPTTokenScript | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
||||||
[ 'shide', OPTTokenShide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
[ 'shide', OPTTokenShide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
/* synonym */ [ 'specifichide', OPTTokenShide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
/* synonym */ [ 'specifichide', OPTTokenShide | OPTNonNetworkType | OPTNonCspableType | OPTNonRedirectableType ],
|
||||||
|
[ 'to', OPTTokenTo | OPTMustAssign | OPTDomainList ],
|
||||||
[ 'xhr', OPTTokenXhr | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
[ 'xhr', OPTTokenXhr | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
||||||
/* synonym */ [ 'xmlhttprequest', OPTTokenXhr | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
/* synonym */ [ 'xmlhttprequest', OPTTokenXhr | OPTCanNegate | OPTNetworkType | OPTModifiableType | OPTRedirectableType | OPTNonCspableType ],
|
||||||
[ 'webrtc', OPTTokenWebrtc | OPTNotSupported ],
|
[ 'webrtc', OPTTokenWebrtc | OPTNotSupported ],
|
||||||
|
@ -2572,7 +2576,8 @@ Parser.netOptionTokenIds = new Map([
|
||||||
[ 'denyallow', OPTTokenDenyAllow ],
|
[ 'denyallow', OPTTokenDenyAllow ],
|
||||||
[ 'doc', OPTTokenDoc ],
|
[ 'doc', OPTTokenDoc ],
|
||||||
/* synonym */ [ 'document', OPTTokenDoc ],
|
/* synonym */ [ 'document', OPTTokenDoc ],
|
||||||
[ 'domain', OPTTokenDomain ],
|
[ 'from', OPTTokenFrom ],
|
||||||
|
/* synonym */ [ 'domain', OPTTokenFrom ],
|
||||||
[ 'ehide', OPTTokenEhide ],
|
[ 'ehide', OPTTokenEhide ],
|
||||||
/* synonym */ [ 'elemhide', OPTTokenEhide ],
|
/* synonym */ [ 'elemhide', OPTTokenEhide ],
|
||||||
[ 'empty', OPTTokenEmpty ],
|
[ 'empty', OPTTokenEmpty ],
|
||||||
|
@ -2625,11 +2630,11 @@ Parser.netOptionTokenNames = new Map([
|
||||||
[ OPTTokenCss, 'stylesheet' ],
|
[ OPTTokenCss, 'stylesheet' ],
|
||||||
[ OPTTokenDenyAllow, 'denyallow' ],
|
[ OPTTokenDenyAllow, 'denyallow' ],
|
||||||
[ OPTTokenDoc, 'document' ],
|
[ OPTTokenDoc, 'document' ],
|
||||||
[ OPTTokenDomain, 'domain' ],
|
|
||||||
[ OPTTokenEhide, 'elemhide' ],
|
[ OPTTokenEhide, 'elemhide' ],
|
||||||
[ OPTTokenEmpty, 'empty' ],
|
[ OPTTokenEmpty, 'empty' ],
|
||||||
[ OPTTokenFrame, 'subdocument' ],
|
[ OPTTokenFrame, 'subdocument' ],
|
||||||
[ OPTTokenFont, 'font' ],
|
[ OPTTokenFont, 'font' ],
|
||||||
|
[ OPTTokenFrom, 'from' ],
|
||||||
[ OPTTokenGenericblock, 'genericblock' ],
|
[ OPTTokenGenericblock, 'genericblock' ],
|
||||||
[ OPTTokenGhide, 'generichide' ],
|
[ OPTTokenGhide, 'generichide' ],
|
||||||
[ OPTTokenHeader, 'header' ],
|
[ OPTTokenHeader, 'header' ],
|
||||||
|
@ -2652,6 +2657,7 @@ Parser.netOptionTokenNames = new Map([
|
||||||
[ OPTTokenRedirectRule, 'redirect-rule' ],
|
[ OPTTokenRedirectRule, 'redirect-rule' ],
|
||||||
[ OPTTokenScript, 'script' ],
|
[ OPTTokenScript, 'script' ],
|
||||||
[ OPTTokenShide, 'specifichide' ],
|
[ OPTTokenShide, 'specifichide' ],
|
||||||
|
[ OPTTokenTo, 'to' ],
|
||||||
[ OPTTokenXhr, 'xmlhttprequest' ],
|
[ OPTTokenXhr, 'xmlhttprequest' ],
|
||||||
[ OPTTokenWebrtc, 'webrtc' ],
|
[ OPTTokenWebrtc, 'webrtc' ],
|
||||||
[ OPTTokenWebsocket, 'websocket' ],
|
[ OPTTokenWebsocket, 'websocket' ],
|
||||||
|
@ -2802,7 +2808,7 @@ const NetOptionsIterator = class {
|
||||||
if ( this.interactive && hasBits(descriptor, OPTDomainList) ) {
|
if ( this.interactive && hasBits(descriptor, OPTDomainList) ) {
|
||||||
this.parser.analyzeDomainList(
|
this.parser.analyzeDomainList(
|
||||||
lval + 3, i, BITPipe,
|
lval + 3, i, BITPipe,
|
||||||
tokenId === OPTTokenDomain ? 0b1010 : 0b0000
|
tokenId === OPTTokenDenyAllow ? 0b0000 : 0b1010
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2825,7 +2831,7 @@ const NetOptionsIterator = class {
|
||||||
// `denyallow=` option requires `domain=` option.
|
// `denyallow=` option requires `domain=` option.
|
||||||
{
|
{
|
||||||
const i = this.tokenPos[OPTTokenDenyAllow];
|
const i = this.tokenPos[OPTTokenDenyAllow];
|
||||||
if ( i !== -1 && this.tokenPos[OPTTokenDomain] === -1 ) {
|
if ( i !== -1 && this.tokenPos[OPTTokenFrom] === -1 ) {
|
||||||
optSlices[i] = OPTTokenInvalid;
|
optSlices[i] = OPTTokenInvalid;
|
||||||
if ( this.interactive ) {
|
if ( this.interactive ) {
|
||||||
this.parser.errorSlices(optSlices[i+1], optSlices[i+5]);
|
this.parser.errorSlices(optSlices[i+1], optSlices[i+5]);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue