Skip to content

Commit b77cb75

Browse files
committed
forbit empty punycoded hostnames
1 parent 8421a77 commit b77cb75

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/content_blocking.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,8 @@ mod filterset_tests {
13651365
"||insaattrendy.com/Upload/bükerbanner*.jpg",
13661366
// from domain
13671367
"/siropu/am/core.min.js$script,important,from=~audi-sport.net|~hifiwigwam.com",
1368+
// leading zero-width space
1369+
r#"​##a[href^="https://www.g2fame.com/"] > img"#,
13681370
], Default::default());
13691371

13701372
let (cb_rules, used_rules) = set.into_content_blocking()?;

src/filters/cosmetic.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ impl CosmeticFilter {
192192
} else {
193193
*mask |= CosmeticFilterMask::IS_UNICODE;
194194
match idna::domain_to_ascii(location) {
195-
Ok(x) => hostname.push_str(&x),
196-
Err(_) => return Err(CosmeticFilterError::PunycodeError),
195+
Ok(x) if !x.is_empty() => hostname.push_str(&x),
196+
_ => return Err(CosmeticFilterError::PunycodeError),
197197
}
198198
}
199199
let hash = crate::utils::fast_hash(&hostname);
@@ -1982,6 +1982,11 @@ mod matching_tests {
19821982
assert!(parse_cf("example.com###adBanner:remove-class(src)").is_ok());
19831983
}
19841984

1985+
#[test]
1986+
fn zero_width_space() {
1987+
assert!(parse_cf(r#"​##a[href^="https://www.g2fame.com/"] > img"#).is_err());
1988+
}
1989+
19851990
#[test]
19861991
#[cfg(feature = "css-validation")]
19871992
fn abp_has_conversion() {

0 commit comments

Comments
 (0)