From eaa23e556f8f6de3c2c92ff16ceab9d554c52969 Mon Sep 17 00:00:00 2001 From: crowlkats Date: Wed, 7 Sep 2022 12:03:02 +0200 Subject: [PATCH] remove IDNA feature --- url/Cargo.toml | 4 ++-- url/src/host.rs | 13 ------------- url/src/origin.rs | 1 - url/src/parser.rs | 1 - url/src/quirks.rs | 1 - url/tests/data.rs | 3 --- url/tests/unit.rs | 3 --- 7 files changed, 2 insertions(+), 24 deletions(-) diff --git a/url/Cargo.toml b/url/Cargo.toml index 1eaf15526..64704757a 100644 --- a/url/Cargo.toml +++ b/url/Cargo.toml @@ -29,12 +29,12 @@ debugger_test_parser = "0.1" [dependencies] form_urlencoded = { version = "1.0.0", path = "../form_urlencoded" } -idna = { version = "0.2.0", path = "../idna", optional = true } +idna = { version = "0.2.0", path = "../idna" } percent-encoding = { version = "2.1.0", path = "../percent_encoding" } serde = {version = "1.0", optional = true, features = ["derive"]} [features] -default = ["idna"] +default = [] # UNSTABLE FEATURES (requires Rust nightly) # Enable to use the #[debugger_visualizer] attribute. debugger_visualizer = [] diff --git a/url/src/host.rs b/url/src/host.rs index 4678cb8a1..f1921c654 100644 --- a/url/src/host.rs +++ b/url/src/host.rs @@ -162,22 +162,9 @@ impl Host { } /// convert domain with idna - #[cfg(feature = "idna")] fn domain_to_ascii(domain: &str) -> Result { idna::domain_to_ascii(domain).map_err(Into::into) } - - /// checks domain is ascii - #[cfg(not(feature = "idna"))] - fn domain_to_ascii(domain: &str) -> Result { - // without idna feature, we can't verify that xn-- domains correctness - let domain = domain.to_lowercase(); - if domain.is_ascii() && domain.split('.').all(|s| !s.starts_with("xn--")) { - Ok(domain) - } else { - Err(ParseError::InvalidDomainCharacter) - } - } } impl> fmt::Display for Host { diff --git a/url/src/origin.rs b/url/src/origin.rs index 838be55bd..81193f510 100644 --- a/url/src/origin.rs +++ b/url/src/origin.rs @@ -86,7 +86,6 @@ impl Origin { } /// - #[cfg(feature = "idna")] pub fn unicode_serialization(&self) -> String { match *self { Origin::Opaque(_) => "null".to_owned(), diff --git a/url/src/parser.rs b/url/src/parser.rs index b83bdd4f6..f5438c505 100644 --- a/url/src/parser.rs +++ b/url/src/parser.rs @@ -87,7 +87,6 @@ simple_enum_error! { Overflow => "URLs more than 4 GB are not supported", } -#[cfg(feature = "idna")] impl From<::idna::Errors> for ParseError { fn from(_: ::idna::Errors) -> ParseError { ParseError::IdnaError diff --git a/url/src/quirks.rs b/url/src/quirks.rs index 3a5106402..0674ebb62 100644 --- a/url/src/quirks.rs +++ b/url/src/quirks.rs @@ -66,7 +66,6 @@ pub fn domain_to_ascii(domain: &str) -> String { } /// https://url.spec.whatwg.org/#dom-url-domaintounicode -#[cfg(feature = "idna")] pub fn domain_to_unicode(domain: &str) -> String { match Host::parse(domain) { Ok(Host::Domain(ref domain)) => { diff --git a/url/tests/data.rs b/url/tests/data.rs index e0547080e..f4001ca2b 100644 --- a/url/tests/data.rs +++ b/url/tests/data.rs @@ -15,7 +15,6 @@ use url::{quirks, Url}; #[test] fn urltestdata() { - #[cfg(not(feature = "idna"))] let idna_skip_inputs = [ "http://www.foo。bar.com", "http://Go.com", @@ -46,7 +45,6 @@ fn urltestdata() { let input = entry.take_string("input"); let failure = entry.take_key("failure").is_some(); - #[cfg(not(feature = "idna"))] { if idna_skip_inputs.contains(&input.as_str()) { continue; @@ -133,7 +131,6 @@ fn setters_tests() { let mut tests = json.take_key(attr).unwrap(); for mut test in tests.as_array_mut().unwrap().drain(..) { let comment = test.take_key("comment").map(|s| s.string()); - #[cfg(not(feature = "idna"))] { if let Some(comment) = comment.as_ref() { if comment.starts_with("IDNA Nontransitional_Processing") { diff --git a/url/tests/unit.rs b/url/tests/unit.rs index b0fd5a3c1..55ff59ada 100644 --- a/url/tests/unit.rs +++ b/url/tests/unit.rs @@ -304,7 +304,6 @@ fn host_serialization() { ); } -#[cfg(feature = "idna")] #[test] fn test_idna() { assert!("http://goșu.ro".parse::().is_ok()); @@ -540,7 +539,6 @@ fn test_origin_opaque() { assert!(!&Url::parse("blob:malformed//").unwrap().origin().is_tuple()) } -#[cfg(feature = "idna")] #[test] fn test_origin_unicode_serialization() { let data = [ @@ -713,7 +711,6 @@ fn test_set_href() { ); } -#[cfg(feature = "idna")] #[test] fn test_domain_encoding_quirks() { use url::quirks::{domain_to_ascii, domain_to_unicode};