Skip to content

Commit

Permalink
Fix Ipv6Addr to_str for ::1:x.x.x.x addresses
Browse files Browse the repository at this point in the history
Reported by luqmana@
  • Loading branch information
stepancheg committed Aug 9, 2013
1 parent 094e426 commit ae81151
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libstd/rt/io/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl ToStr for IpAddr {
}

// Ipv4-Mapped address
Ipv6Addr(0, 0, 0, 0, 0, 1, g, h) => {
Ipv6Addr(0, 0, 0, 0, 0, 0xFFFF, g, h) => {
let a = fmt!("%04x", g as uint);
let b = FromStrRadix::from_str_radix(a.slice(2, 4), 16).unwrap();
let a = FromStrRadix::from_str_radix(a.slice(0, 2), 16).unwrap();
Expand Down Expand Up @@ -437,4 +437,11 @@ mod test {
// port out of range
assert_eq!(None, FromStr::from_str::<SocketAddr>("127.0.0.1:123456"));
}

#[test]
fn ipv6_addr_to_str() {
let a1 = Ipv6Addr(0, 0, 0, 0, 0, 0xffff, 0xc000, 0x280);
assert!(a1.to_str() == ~"::ffff:192.0.2.128" || a1.to_str() == ~"::FFFF:192.0.2.128");
}

}

5 comments on commit ae81151

@bors
Copy link
Contributor

@bors bors commented on ae81151 Aug 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from luqmana
at stepancheg@ae81151

@bors
Copy link
Contributor

@bors bors commented on ae81151 Aug 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging stepancheg/rust/ipv6-to-str = ae81151 into auto

@bors
Copy link
Contributor

@bors bors commented on ae81151 Aug 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stepancheg/rust/ipv6-to-str = ae81151 merged ok, testing candidate = 74efdf6

@bors
Copy link
Contributor

@bors bors commented on ae81151 Aug 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 74efdf6

Please sign in to comment.