Skip to content

Commit

Permalink
Auto merge of servo#240 - canaltinova:idna, r=SimonSapin
Browse files Browse the repository at this point in the history
Ignore UTS46 validity criteria V2

Fixes servo#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 -->
  • Loading branch information
bors-servo authored Nov 22, 2016
2 parents 42921c8 + 695a507 commit 52234db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 4 additions & 6 deletions idna/src/uts46.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions tests/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 52234db

Please sign in to comment.