diff --git a/src/content_blocking.rs b/src/content_blocking.rs index 128d202f..77b12f9b 100644 --- a/src/content_blocking.rs +++ b/src/content_blocking.rs @@ -464,7 +464,9 @@ impl TryFrom for CbRuleEquivalent { } else { // The network filter has already parsed successfully, so this should be // safe - idna::domain_to_ascii(&lowercase).unwrap() + idna::domain_to_ascii_cow(&lowercase.as_bytes(), idna::AsciiDenyList::EMPTY) + .unwrap() + .to_string() }; collection.push(format!("*{normalized_domain}")); @@ -616,13 +618,19 @@ impl TryFrom for CbRule { any_unsupported = true } LocationType::Hostname => { - if let Ok(encoded) = idna::domain_to_ascii(location) { - hostnames_vec.push(encoded); + if let Ok(encoded) = idna::domain_to_ascii_cow( + location.as_bytes(), + idna::AsciiDenyList::EMPTY, + ) { + hostnames_vec.push(encoded.to_string()); } } LocationType::NotHostname => { - if let Ok(encoded) = idna::domain_to_ascii(location) { - not_hostnames_vec.push(encoded); + if let Ok(encoded) = idna::domain_to_ascii_cow( + location.as_bytes(), + idna::AsciiDenyList::EMPTY, + ) { + not_hostnames_vec.push(encoded.to_string()); } } }, diff --git a/src/filters/cosmetic.rs b/src/filters/cosmetic.rs index 37ea8970..811b4351 100644 --- a/src/filters/cosmetic.rs +++ b/src/filters/cosmetic.rs @@ -228,7 +228,7 @@ impl CosmeticFilter { if location.is_ascii() { hostname.push_str(location); } else { - match idna::domain_to_ascii(location) { + match idna::domain_to_ascii_cow(location.as_bytes(), idna::AsciiDenyList::EMPTY) { Ok(x) if !x.is_empty() => hostname.push_str(&x), _ => return Err(CosmeticFilterError::PunycodeError), } diff --git a/src/url_parser/parser.rs b/src/url_parser/parser.rs index 66bcd485..3308352f 100644 --- a/src/url_parser/parser.rs +++ b/src/url_parser/parser.rs @@ -531,7 +531,8 @@ impl Parser { if host_str.is_ascii() { write!(&mut self.serialization, "{host_str}").unwrap(); } else { - let encoded = idna::domain_to_ascii(host_str)?; + let encoded = + idna::domain_to_ascii_cow(host_str.as_bytes(), idna::AsciiDenyList::EMPTY)?; write!(&mut self.serialization, "{encoded}").unwrap(); }