Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std: Fix peeling ports from addresses #23097

Merged
merged 1 commit into from
Mar 7, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/libstd/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ impl ToSocketAddrs for str {
}

// split the string by ':' and convert the second part to u16
let mut parts_iter = self.rsplitn(2, ':');
let mut parts_iter = self.rsplitn(1, ':');
let port_str = try_opt!(parts_iter.next(), "invalid socket address");
let host = try_opt!(parts_iter.next(), "invalid socket address");
let port: u16 = try_opt!(port_str.parse().ok(), "invalid port value");
Expand Down Expand Up @@ -590,4 +590,9 @@ mod tests {
let a = SocketAddr::new(IpAddr::new_v4(127, 0, 0, 1), 23924);
assert!(tsa("localhost:23924").unwrap().contains(&a));
}

#[test]
fn to_socket_addr_str_bad() {
assert!(tsa("1200::AB00:1234::2552:7777:1313:34300").is_err());
}
}