mirror of
https://github.com/openharmony/third_party_rust_rust-url.git
synced 2026-07-19 14:33:31 -04:00
Merge pull request #790 from crowlKats/remove_idna
Make IDNA dependency non-optional
This commit is contained in:
+2
-2
@@ -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 = []
|
||||
|
||||
@@ -162,22 +162,9 @@ impl Host<String> {
|
||||
}
|
||||
|
||||
/// convert domain with idna
|
||||
#[cfg(feature = "idna")]
|
||||
fn domain_to_ascii(domain: &str) -> Result<String, ParseError> {
|
||||
idna::domain_to_ascii(domain).map_err(Into::into)
|
||||
}
|
||||
|
||||
/// checks domain is ascii
|
||||
#[cfg(not(feature = "idna"))]
|
||||
fn domain_to_ascii(domain: &str) -> Result<String, ParseError> {
|
||||
// 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<S: AsRef<str>> fmt::Display for Host<S> {
|
||||
|
||||
@@ -86,7 +86,6 @@ impl Origin {
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#unicode-serialisation-of-an-origin>
|
||||
#[cfg(feature = "idna")]
|
||||
pub fn unicode_serialization(&self) -> String {
|
||||
match *self {
|
||||
Origin::Opaque(_) => "null".to_owned(),
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)) => {
|
||||
|
||||
@@ -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") {
|
||||
|
||||
@@ -304,7 +304,6 @@ fn host_serialization() {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "idna")]
|
||||
#[test]
|
||||
fn test_idna() {
|
||||
assert!("http://goșu.ro".parse::<Url>().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};
|
||||
|
||||
Reference in New Issue
Block a user