File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ pub enum CosmeticFilterError {
28
28
GenericUnhide ,
29
29
#[ error( "generic script inject" ) ]
30
30
GenericScriptInject ,
31
- #[ error( "generic action" ) ]
31
+ #[ error( "procedural and action filters cannot be generic " ) ]
32
32
GenericAction ,
33
33
#[ error( "double negation" ) ]
34
34
DoubleNegation ,
@@ -443,7 +443,7 @@ impl CosmeticFilter {
443
443
return Err ( CosmeticFilterError :: DoubleNegation ) ;
444
444
}
445
445
446
- Ok ( CosmeticFilter {
446
+ let this = Self {
447
447
entities,
448
448
hostnames,
449
449
mask,
@@ -457,7 +457,13 @@ impl CosmeticFilter {
457
457
selector,
458
458
action,
459
459
permission,
460
- } )
460
+ } ;
461
+
462
+ if !this. has_hostname_constraint ( ) && this. plain_css_selector ( ) . is_none ( ) {
463
+ return Err ( CosmeticFilterError :: GenericAction ) ;
464
+ }
465
+
466
+ Ok ( this)
461
467
} else {
462
468
Err ( CosmeticFilterError :: MissingSharp )
463
469
}
@@ -1845,6 +1851,9 @@ mod parse_tests {
1845
1851
1846
1852
// `:has-text` and `:xpath` are now supported procedural filters
1847
1853
assert ! ( parse_cf( "twitter.com##article:has-text(/Promoted|Gesponsert|Реклама|Promocionado/):xpath(../..)" ) . is_ok( ) ) ;
1854
+
1855
+ // generic procedural filters are not supported
1856
+ assert ! ( parse_cf( "##.t-rec > .t886:has-text(cookies)" ) . is_err( ) ) ;
1848
1857
}
1849
1858
1850
1859
#[ test]
You can’t perform that action at this time.
0 commit comments