Skip to content

Commit 6c0c120

Browse files
authored
Merge pull request #349 from brave/forbid-adguard-cosmetic-modifiers
Forbid adguard cosmetic modifiers for now
2 parents a337c18 + 0ba4fad commit 6c0c120

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/filters/cosmetic.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ pub enum CosmeticFilterError {
4040
HtmlFilteringUnsupported,
4141
#[error("scriptlet args could not be parsed")]
4242
InvalidScriptletArgs,
43+
#[error("location modifiers are unsupported")]
44+
LocationModifiersUnsupported,
4345
}
4446

4547
/// Refer to <https://github.com/uBlockOrigin/uBlock-issues/wiki/Static-filter-syntax#action-operators>
@@ -179,6 +181,10 @@ impl CosmeticFilter {
179181
let mut hostnames_vec = vec![];
180182
let mut not_hostnames_vec = vec![];
181183

184+
if line.starts_with('[') {
185+
return Err(CosmeticFilterError::LocationModifiersUnsupported);
186+
}
187+
182188
for (location_type, location) in Self::locations_before_sharp(line, sharp_index) {
183189
let mut hostname = String::new();
184190
if location.is_ascii() {

src/lists.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,16 @@ mod tests {
617617
let result = parse_filter(input, true, Default::default());
618618
assert!(result.is_ok());
619619
}
620+
{
621+
let input = "[$app=org.example.app]example.com##.textad";
622+
let result = parse_filter(input, true, Default::default());
623+
assert!(result.is_err());
624+
}
625+
{
626+
let input = r#"[$domain=/^i\[a-z\]*\.strmrdr\[a-z\]+\..*/]##+js(set-constant, adscfg.enabled, false)"#;
627+
let result = parse_filter(input, true, Default::default());
628+
assert!(result.is_err());
629+
}
620630
}
621631

622632
#[test]

0 commit comments

Comments
 (0)