1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix the IPv6 parser.

* lib/ipaddr.rb (IPAddr#in6_addr): Fix the parser so that it can
  recognize IPv6 addresses with only one edge 16-bit piece
  compressed, like [::2:3:4:5:6:7:8] or [1:2:3:4:5:6:7::].
  [Bug #7477]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2013-02-18 03:45:21 +00:00
parent e8c57cd850
commit 7d63004fce
2 changed files with 13 additions and 1 deletions

View file

@ -1,3 +1,10 @@
Mon Feb 18 12:32:24 2013 Akinori MUSHA <knu@iDaemons.org>
* lib/ipaddr.rb (IPAddr#in6_addr): Fix the parser so that it can
recognize IPv6 addresses with only one edge 16-bit piece
compressed, like [::2:3:4:5:6:7:8] or [1:2:3:4:5:6:7::].
[Bug #7477]
Mon Feb 18 10:09:54 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (unexpand_shvar): regularize a shell variable by

View file

@ -549,7 +549,8 @@ class IPAddr
left = $1
right = $3 + '0:0'
else
left.count(':') <= 7 or raise InvalidAddressError, "invalid address"
left.count(':') <= ($1.empty? || $2.empty?) ? 8 : 7 or
raise InvalidAddressError, "invalid address"
left = $1
right = $2
addr = 0
@ -671,6 +672,8 @@ class TC_IPAddr < Test::Unit::TestCase
["0:0:0:1::"],
["2001:200:300::/48"],
["2001:200:300::192.168.1.2/48"],
["1:2:3:4:5:6:7::"],
["::2:3:4:5:6:7:8"],
].each { |args|
assert_nothing_raised {
IPAddr.new(*args)
@ -727,6 +730,8 @@ class TC_IPAddr < Test::Unit::TestCase
assert_equal("2001:200:300::", IPAddr.new("2001:200:300::/48").to_s)
assert_equal("2001:200:300::", IPAddr.new("[2001:200:300::]/48").to_s)
assert_equal("1:2:3:4:5:6:7:0", IPAddr.new("1:2:3:4:5:6:7::").to_s)
assert_equal("0:2:3:4:5:6:7:8", IPAddr.new("::2:3:4:5:6:7:8").to_s)
assert_raises(IPAddr::InvalidAddressError) { IPAddr.new("192.168.0.256") }
assert_raises(IPAddr::InvalidAddressError) { IPAddr.new("192.168.0.011") }