mirror of
https://github.com/golang/go
synced 2024-11-25 10:17:57 -07:00
net: fix ParseIP
Fixes #1695. R=golang-dev, rsc CC=golang-dev, r https://golang.org/cl/4418042
This commit is contained in:
parent
24bb0340b6
commit
c09af6631f
@ -436,7 +436,7 @@ func parseIPv6(s string) IP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise must be followed by colon and more.
|
// Otherwise must be followed by colon and more.
|
||||||
if s[i] != ':' && i+1 == len(s) {
|
if s[i] != ':' || i+1 == len(s) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
|
@ -29,6 +29,7 @@ var parseiptests = []struct {
|
|||||||
{"127.0.0.1", IPv4(127, 0, 0, 1)},
|
{"127.0.0.1", IPv4(127, 0, 0, 1)},
|
||||||
{"127.0.0.256", nil},
|
{"127.0.0.256", nil},
|
||||||
{"abc", nil},
|
{"abc", nil},
|
||||||
|
{"123:", nil},
|
||||||
{"::ffff:127.0.0.1", IPv4(127, 0, 0, 1)},
|
{"::ffff:127.0.0.1", IPv4(127, 0, 0, 1)},
|
||||||
{"2001:4860:0:2001::68",
|
{"2001:4860:0:2001::68",
|
||||||
IP{0x20, 0x01, 0x48, 0x60, 0, 0, 0x20, 0x01,
|
IP{0x20, 0x01, 0x48, 0x60, 0, 0, 0x20, 0x01,
|
||||||
|
Loading…
Reference in New Issue
Block a user