@@ -4452,22 +4452,23 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar
4452
4452
}
4453
4453
4454
4454
// Priority:
4455
- // Block: 1 (default priority)
4456
- // Redirect: 2-9
4457
- // Excepted redirect: 12-19
4458
- // Allow: 20
4459
- // Block important: 30
4460
- // Redirect important: 32-39
4455
+ // Removeparam: 1-4
4456
+ // Block: 10 (default priority)
4457
+ // Redirect: 11-19
4458
+ // Excepted redirect: 21-29
4459
+ // Allow: 30
4460
+ // Block important: 40
4461
+ // Redirect important: 41-49
4461
4462
4462
4463
const realms = new Map ( [
4463
- [ BLOCK_REALM , { type : 'block' , priority : 0 } ] ,
4464
- [ ALLOW_REALM , { type : 'allow' , priority : 20 } ] ,
4465
- [ REDIRECT_REALM , { type : 'redirect' , priority : 2 } ] ,
4464
+ [ BLOCK_REALM , { type : 'block' , priority : 10 } ] ,
4465
+ [ ALLOW_REALM , { type : 'allow' , priority : 30 } ] ,
4466
+ [ REDIRECT_REALM , { type : 'redirect' , priority : 11 } ] ,
4466
4467
[ REMOVEPARAM_REALM , { type : 'removeparam' , priority : 0 } ] ,
4467
4468
[ CSP_REALM , { type : 'csp' , priority : 0 } ] ,
4468
4469
[ PERMISSIONS_REALM , { type : 'permissions' , priority : 0 } ] ,
4469
4470
[ URLTRANSFORM_REALM , { type : 'uritransform' , priority : 0 } ] ,
4470
- [ HEADERS_REALM , { type : 'block' , priority : 0 } ] ,
4471
+ [ HEADERS_REALM , { type : 'block' , priority : 10 } ] ,
4471
4472
[ URLSKIP_REALM , { type : 'urlskip' , priority : 0 } ] ,
4472
4473
] ) ;
4473
4474
const partyness = new Map ( [
@@ -4605,7 +4606,7 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar
4605
4606
if ( token !== '' ) {
4606
4607
const match = / : ( \d + ) $ / . exec ( token ) ;
4607
4608
if ( match !== null ) {
4608
- rule . priority = Math . min ( rule . priority + parseInt ( match [ 1 ] , 10 ) , 9 ) ;
4609
+ rule . priority + = Math . min ( rule . priority + parseInt ( match [ 1 ] , 10 ) , 9 ) ;
4609
4610
token = token . slice ( 0 , match . index ) ;
4610
4611
}
4611
4612
}
@@ -4623,7 +4624,7 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar
4623
4624
}
4624
4625
break ;
4625
4626
}
4626
- case 'removeparam' :
4627
+ case 'removeparam' : {
4627
4628
rule . action . type = 'redirect' ;
4628
4629
if ( rule . __modifierValue === '|' ) {
4629
4630
rule . __modifierValue = '' ;
@@ -4657,10 +4658,21 @@ StaticNetFilteringEngine.prototype.dnrFromCompiled = function(op, context, ...ar
4657
4658
'xmlhttprequest' ,
4658
4659
] ;
4659
4660
}
4661
+ // https://github.com/uBlockOrigin/uBOL-home/issues/140
4662
+ // Mitigate until DNR API flaw is addressed by browser vendors
4663
+ let priority = rule . priority || 1 ;
4664
+ if ( rule . condition . urlFilter !== undefined ) { priority += 1 ; }
4665
+ if ( rule . condition . regexFilter !== undefined ) { priority += 1 ; }
4666
+ if ( rule . condition . initiatorDomains !== undefined ) { priority += 1 ; }
4667
+ if ( rule . condition . requestDomains !== undefined ) { priority += 1 ; }
4668
+ if ( priority !== 1 ) {
4669
+ rule . priority = priority ;
4670
+ }
4660
4671
if ( rule . __modifierAction === ALLOW_REALM ) {
4661
4672
dnrAddRuleError ( rule , `Unsupported removeparam exception: ${ rule . __modifierValue } ` ) ;
4662
4673
}
4663
4674
break ;
4675
+ }
4664
4676
case 'uritransform' : {
4665
4677
dnrAddRuleError ( rule , `Incompatible with DNR: uritransform=${ rule . __modifierValue } ` ) ;
4666
4678
break ;
0 commit comments