@@ -1740,11 +1740,6 @@ const FilterOriginEntityHit = class extends FilterOriginHit {
1740
1740
static compile ( entity ) {
1741
1741
return [ FilterOriginEntityHit . fid , entity ] ;
1742
1742
}
1743
-
1744
- static dnrFromCompiled ( args , rule ) {
1745
- dnrAddRuleError ( rule , `FilterOriginEntityHit: Entity ${ args [ 1 ] } not supported` ) ;
1746
- super . dnrFromCompiled ( args , rule ) ;
1747
- }
1748
1743
} ;
1749
1744
1750
1745
registerFilterClass ( FilterOriginEntityHit ) ;
@@ -1759,11 +1754,6 @@ const FilterOriginEntityMiss = class extends FilterOriginMiss {
1759
1754
static compile ( entity ) {
1760
1755
return [ FilterOriginEntityMiss . fid , entity ] ;
1761
1756
}
1762
-
1763
- static dnrFromCompiled ( args , rule ) {
1764
- dnrAddRuleError ( rule , `FilterOriginEntityMiss: Entity ${ args [ 1 ] } not supported` ) ;
1765
- super . dnrFromCompiled ( args , rule ) ;
1766
- }
1767
1757
} ;
1768
1758
1769
1759
registerFilterClass ( FilterOriginEntityMiss ) ;
@@ -4062,6 +4052,36 @@ FilterContainer.prototype.dnrFromCompiled = function(op, context, ...args) {
4062
4052
}
4063
4053
}
4064
4054
4055
+ // Detect and attempt salvage of rules with entity-based hostnames.
4056
+ for ( const rule of ruleset ) {
4057
+ if ( rule . condition === undefined ) { continue ; }
4058
+ if (
4059
+ Array . isArray ( rule . condition . initiatorDomains ) &&
4060
+ rule . condition . initiatorDomains . some ( hn => hn . endsWith ( '.*' ) )
4061
+ ) {
4062
+ const domains = rule . condition . initiatorDomains . filter (
4063
+ hn => hn . endsWith ( '.*' ) === false
4064
+ ) ;
4065
+ if ( domains . length === 0 ) {
4066
+ dnrAddRuleError ( rule , `Could not salvage rule with only entity-based domain= option: ${ rule . condition . initiatorDomains . join ( '|' ) } ` ) ;
4067
+ } else {
4068
+ rule . condition . initiatorDomains = domains ;
4069
+ }
4070
+ }
4071
+ if (
4072
+ Array . isArray ( rule . condition . excludedInitiatorDomains ) &&
4073
+ rule . condition . excludedInitiatorDomains . some ( hn => hn . endsWith ( '.*' ) )
4074
+ ) {
4075
+ const domains = rule . condition . excludedInitiatorDomains . filter (
4076
+ hn => hn . endsWith ( '.*' ) === false
4077
+ ) ;
4078
+ rule . condition . excludedInitiatorDomains =
4079
+ domains . length !== 0
4080
+ ? domains
4081
+ : undefined ;
4082
+ }
4083
+ }
4084
+
4065
4085
// Patch modifier filters
4066
4086
for ( const rule of ruleset ) {
4067
4087
if ( rule . __modifierType === undefined ) { continue ; }
0 commit comments