diff --git a/idna/src/uts46.rs b/idna/src/uts46.rs index bfe12ff26..af2a63139 100644 --- a/idna/src/uts46.rs +++ b/idna/src/uts46.rs @@ -198,12 +198,10 @@ fn validate(label: &str, flags: Flags, errors: &mut Vec) { } // Can not contain '.' since the input is from .split('.') - if { - let mut chars = label.chars().skip(2); - let third = chars.next(); - let fourth = chars.next(); - (third, fourth) == (Some('-'), Some('-')) - } || label.starts_with("-") + // Spec says that the label must not contain a HYPHEN-MINUS character in both the + // third and fourth positions. But nobody follows this criteria. See the spec issue below: + // https://github.com/whatwg/url/issues/53 + if label.starts_with("-") || label.ends_with("-") || label.chars().next().map_or(false, is_combining_mark) || label.chars().any(|c| match *find_char(c) { diff --git a/tests/unit.rs b/tests/unit.rs index 8a1d6794c..eb460015d 100644 --- a/tests/unit.rs +++ b/tests/unit.rs @@ -202,6 +202,7 @@ fn host_serialization() { fn test_idna() { assert!("http://goșu.ro".parse::().is_ok()); assert_eq!(Url::parse("http://☃.net/").unwrap().host(), Some(Host::Domain("xn--n3h.net"))); + assert!("https://r2---sn-huoa-cvhl.googlevideo.com/crossdomain.xml".parse::().is_ok()); } #[test]