mirror of https://github.com/golang/go.git
net: ParseIP should return nil if :: doesn't expand in an IPv6 address.
Per RFC 4291, 'The use of "::" indicates one or more groups of 16 bits of zeros.' Fixes #6628 R=golang-dev, rsc, minux.ma, mikioh.mikioh CC=golang-dev https://golang.org/cl/15990043
This commit is contained in:
parent
eb7ed0d626
commit
487dff1852
|
|
@ -623,6 +623,9 @@ func parseIPv6(s string, zoneAllowed bool) (ip IP, zone string) {
|
|||
for k := ellipsis + n - 1; k >= ellipsis; k-- {
|
||||
ip[k] = 0
|
||||
}
|
||||
} else if ellipsis >= 0 {
|
||||
// Ellipsis must represent at least one 0 group.
|
||||
return nil, zone
|
||||
}
|
||||
return ip, zone
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ var parseIPTests = []struct {
|
|||
{"fe80::1%lo0", nil},
|
||||
{"fe80::1%911", nil},
|
||||
{"", nil},
|
||||
{"a1:a2:a3:a4::b1:b2:b3:b4", nil}, // Issue 6628
|
||||
}
|
||||
|
||||
func TestParseIP(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue