mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-16 23:42:39 +01:00
[mv3] Slightly mitigate DNR flaw re. removeparam
filters
Related issue: https://github.com/uBlockOrigin/uBOL-home/issues/140 This will allow more specific `removeparam` filters to override generic ones. This doesn't fix the related issue but should help more specific `removeparam` filters to be applied. Related webextensions issue: https://github.com/w3c/webextensions/issues/468
This commit is contained in:
parent
7fcd2a51be
commit
947602d4fe
@ -4452,22 +4452,23 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Priority:
|
// Priority:
|
||||||
// Block: 1 (default priority)
|
// Removeparam: 1-4
|
||||||
// Redirect: 2-9
|
// Block: 10 (default priority)
|
||||||
// Excepted redirect: 12-19
|
// Redirect: 11-19
|
||||||
// Allow: 20
|
// Excepted redirect: 21-29
|
||||||
// Block important: 30
|
// Allow: 30
|
||||||
// Redirect important: 32-39
|
// Block important: 40
|
||||||
|
// Redirect important: 41-49
|
||||||
|
|
||||||
const realms = new Map([
|
const realms = new Map([
|
||||||
[ BLOCK_REALM, { type: 'block', priority: 0 } ],
|
[ BLOCK_REALM, { type: 'block', priority: 10 } ],
|
||||||
[ ALLOW_REALM, { type: 'allow', priority: 20 } ],
|
[ ALLOW_REALM, { type: 'allow', priority: 30 } ],
|
||||||
[ REDIRECT_REALM, { type: 'redirect', priority: 2 } ],
|
[ REDIRECT_REALM, { type: 'redirect', priority: 11 } ],
|
||||||
[ REMOVEPARAM_REALM, { type: 'removeparam', priority: 0 } ],
|
[ REMOVEPARAM_REALM, { type: 'removeparam', priority: 0 } ],
|
||||||
[ CSP_REALM, { type: 'csp', priority: 0 } ],
|
[ CSP_REALM, { type: 'csp', priority: 0 } ],
|
||||||
[ PERMISSIONS_REALM, { type: 'permissions', priority: 0 } ],
|
[ PERMISSIONS_REALM, { type: 'permissions', priority: 0 } ],
|
||||||
[ URLTRANSFORM_REALM, { type: 'uritransform', priority: 0 } ],
|
[ URLTRANSFORM_REALM, { type: 'uritransform', priority: 0 } ],
|
||||||
[ HEADERS_REALM, { type: 'block', priority: 0 } ],
|
[ HEADERS_REALM, { type: 'block', priority: 10 } ],
|
||||||
[ URLSKIP_REALM, { type: 'urlskip', priority: 0 } ],
|
[ URLSKIP_REALM, { type: 'urlskip', priority: 0 } ],
|
||||||
]);
|
]);
|
||||||
const partyness = new Map([
|
const partyness = new Map([
|
||||||
@ -4605,7 +4606,7 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar
|
|||||||
if ( token !== '' ) {
|
if ( token !== '' ) {
|
||||||
const match = /:(\d+)$/.exec(token);
|
const match = /:(\d+)$/.exec(token);
|
||||||
if ( match !== null ) {
|
if ( match !== null ) {
|
||||||
rule.priority = Math.min(rule.priority + parseInt(match[1], 10), 9);
|
rule.priority += Math.min(rule.priority + parseInt(match[1], 10), 9);
|
||||||
token = token.slice(0, match.index);
|
token = token.slice(0, match.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4623,7 +4624,7 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'removeparam':
|
case 'removeparam': {
|
||||||
rule.action.type = 'redirect';
|
rule.action.type = 'redirect';
|
||||||
if ( rule.__modifierValue === '|' ) {
|
if ( rule.__modifierValue === '|' ) {
|
||||||
rule.__modifierValue = '';
|
rule.__modifierValue = '';
|
||||||
@ -4657,10 +4658,21 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar
|
|||||||
'xmlhttprequest',
|
'xmlhttprequest',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
// https://github.com/uBlockOrigin/uBOL-home/issues/140
|
||||||
|
// Mitigate until DNR API flaw is addressed by browser vendors
|
||||||
|
let priority = rule.priority || 1;
|
||||||
|
if ( rule.condition.urlFilter !== undefined ) { priority += 1; }
|
||||||
|
if ( rule.condition.regexFilter !== undefined ) { priority += 1; }
|
||||||
|
if ( rule.condition.initiatorDomains !== undefined ) { priority += 1; }
|
||||||
|
if ( rule.condition.requestDomains !== undefined ) { priority += 1; }
|
||||||
|
if ( priority !== 1 ) {
|
||||||
|
rule.priority = priority;
|
||||||
|
}
|
||||||
if ( rule.__modifierAction === ALLOW_REALM ) {
|
if ( rule.__modifierAction === ALLOW_REALM ) {
|
||||||
dnrAddRuleError(rule, `Unsupported removeparam exception: ${rule.__modifierValue}`);
|
dnrAddRuleError(rule, `Unsupported removeparam exception: ${rule.__modifierValue}`);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'uritransform': {
|
case 'uritransform': {
|
||||||
dnrAddRuleError(rule, `Incompatible with DNR: uritransform=${rule.__modifierValue}`);
|
dnrAddRuleError(rule, `Incompatible with DNR: uritransform=${rule.__modifierValue}`);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user