From 695a5072933c2f834f5d810b77721c1d34df5a32 Mon Sep 17 00:00:00 2001 From: Jesse Ezell Date: Fri, 1 Jul 2016 01:20:55 -0700 Subject: [PATCH] Ignore UTS46 validity criteria V2 --- idna/src/uts46.rs | 10 ++++------ tests/unit.rs | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) 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 55906b8e5..474ac62ba 100644 --- a/tests/unit.rs +++ b/tests/unit.rs @@ -192,6 +192,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]