@@ -635,6 +635,60 @@ mod parse_tests {
635635 ) ;
636636 }
637637
638+ #[ test]
639+ fn escaped_selectors ( ) {
640+ check_parse_result (
641+ r#"temp-mail.io##.fixed.bottom-0.\[\@media\(max-width\:1350px\)\]\:hidden"# ,
642+ CosmeticFilterBreakdown {
643+ selector : SelectorType :: PlainCss (
644+ r#".fixed.bottom-0.\[\@media\(max-width\:1350px\)\]\:hidden"# . to_string ( ) ,
645+ ) ,
646+ hostnames : Some ( vec ! [ 2102614015710080174 ] ) ,
647+ ..Default :: default ( )
648+ } ,
649+ ) ;
650+ check_parse_result (
651+ r#"pinloker.com,sekilastekno.com###main:has(a[\@click="scroll"][target="_blank"]) .entry-content > figure, h3, h4, ol, p, ul"# ,
652+ CosmeticFilterBreakdown {
653+ selector : SelectorType :: PlainCss ( r#"#main:has(a[\@click="scroll"][target="_blank"]) .entry-content > figure, h3, h4, ol, p, ul"# . to_string ( ) ) ,
654+ hostnames : Some ( vec ! [ 6774884157174391526 , 8625775575346486664 ] ) ,
655+ ..Default :: default ( )
656+ }
657+ ) ;
658+
659+ // NOTE: the following `selector` fields are actually invalid selectors, and should keep
660+ // the `\` escape characters from the original rules.
661+ check_parse_result (
662+ r#"pinloker.com,sekilastekno.com##.separator > a[\@click="scroll"][target="_blank"]"# ,
663+ CosmeticFilterBreakdown {
664+ selector : SelectorType :: PlainCss (
665+ r#".separator > a[@click="scroll"][target="_blank"]"# . to_string ( ) ,
666+ ) ,
667+ hostnames : Some ( vec ! [ 6774884157174391526 , 8625775575346486664 ] ) ,
668+ ..Default :: default ( )
669+ } ,
670+ ) ;
671+ check_parse_result (
672+ r#"senpai-stream.net##div[wire\:click="watching"]:style(display: flex !important;)"# ,
673+ CosmeticFilterBreakdown {
674+ selector : SelectorType :: PlainCss ( r#"div[wire:click="watching"]"# . to_string ( ) ) ,
675+ action : Some ( CosmeticFilterAction :: Style (
676+ "display: flex !important;" . to_string ( ) ,
677+ ) ) ,
678+ hostnames : Some ( vec ! [ 12306889736704683473 ] ) ,
679+ ..Default :: default ( )
680+ } ,
681+ ) ;
682+ check_parse_result (
683+ r#"presearch.com##div[\:class*="AdClass"]"# ,
684+ CosmeticFilterBreakdown {
685+ selector : SelectorType :: PlainCss ( r#"div[:class*="AdClass"]"# . to_string ( ) ) ,
686+ hostnames : Some ( vec ! [ 15231640029204839219 ] ) ,
687+ ..Default :: default ( )
688+ } ,
689+ ) ;
690+ }
691+
638692 /// As of writing, these procedural filters with multiple comma-separated selectors aren't
639693 /// fully supported by uBO. Here, they are treated as parsing errors.
640694 #[ test]
0 commit comments