From: "knu (Akinori MUSHA)" Date: 2013-02-18T12:31:22+09:00 Subject: [ruby-core:52429] [ruby-trunk - Bug #7477] Certain valid IPv6 Addresses are not recognized as valid Issue #7477 has been updated by knu (Akinori MUSHA). Thanks for the catch! Your fix doesn't seem quite right when the left part is empty, so I'll make a correct fix shortly with some tests. ---------------------------------------- Bug #7477: Certain valid IPv6 Addresses are not recognized as valid https://bugs.ruby-lang.org/issues/7477#change-36486 Author: alankessler (Alan Kessler) Status: Assigned Priority: Normal Assignee: knu (Akinori MUSHA) Category: lib Target version: 2.0.0 ruby -v: 1.9.3p327 IPv6 addresses of the format: ::2:3:4:5:6:7:8 and 2:3:4:5:6:7:8:: improperly raise an InvalidAddressError This is because this line (https://github.com/ruby/ruby/blob/trunk/lib/ipaddr.rb#L552) ignores the edge cases where there are 8 colons but the IPv6 still matches the compressed format (RE_IPV6ADDRLIKE_COMPRESSED). the following patch will resolve this bug. --- ipaddr.rb 2012-11-29 22:11:05.000000000 -0800 +++ ipaddrpatch.rb 2012-11-29 22:07:30.000000000 -0800 @@ -548,11 +548,15 @@ addr = in_addr($~[4,4]) left = $1 right = $3 + '0:0' - else + elsif !($1 == "" or $2 == "") left.count(':') <= 7 or raise InvalidAddressError, "invalid address" left = $1 right = $2 addr = 0 + else + left = $1 + $2 + right = "" + addr = 0 end else -- http://bugs.ruby-lang.org/