ソースを参照

Auto merge of #240 - canaltinova:idna, r=SimonSapin

Ignore UTS46 validity criteria V2

Fixes #160
r? @SimonSapin or @Manishearth

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/240)
<!-- Reviewable:end -->
bors-servo 9 年 前
コミット
52234db0c3
2 ファイル変更5 行追加6 行削除
  1. 4 6
      idna/src/uts46.rs
  2. 1 0
      tests/unit.rs

+ 4 - 6
idna/src/uts46.rs

@@ -198,12 +198,10 @@ fn validate(label: &str, flags: Flags, errors: &mut Vec<Error>) {
     }
 
     // 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) {

+ 1 - 0
tests/unit.rs

@@ -202,6 +202,7 @@ fn host_serialization() {
 fn test_idna() {
     assert!("http://goșu.ro".parse::<Url>().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::<Url>().is_ok());
 }
 
 #[test]