Issue #7477 has been reported by alankessler (Alan Kessler).

----------------------------------------
Bug #7477: Certain valid IPv6 Addresses are not recognized as valid
https://bugs.ruby-lang.org/issues/7477

Author: alankessler (Alan Kessler)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 
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/