зеркало из https://github.com/github/ruby.git
[ruby/ipaddr] Ipaddr#native must also coerce `@mask_addr`
Before it would be left as an IPv6 mask causing `to_range` to fail. ``` >> IPAddr.new("::2").native.to_range /opt/rubies/3.0.3/lib/ruby/3.0.0/ipaddr.rb:479:in `set': invalid address (IPAddr::InvalidAddressError) ``` https://github.com/ruby/ipaddr/commit/af485192f3
This commit is contained in:
Родитель
5221cb4468
Коммит
100253c7f0
|
@ -510,6 +510,9 @@ class IPAddr
|
|||
@addr = addr
|
||||
if family[0]
|
||||
@family = family[0]
|
||||
if @family == Socket::AF_INET
|
||||
@mask_addr &= IN4MASK
|
||||
end
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
|
|
@ -360,6 +360,11 @@ class TC_Operator < Test::Unit::TestCase
|
|||
|
||||
end
|
||||
|
||||
def test_native_coerce_mask_addr
|
||||
assert_equal(IPAddr.new("0.0.0.2/255.255.255.255"), IPAddr.new("::2").native)
|
||||
assert_equal(IPAddr.new("0.0.0.2/255.255.255.255").to_range, IPAddr.new("::2").native.to_range)
|
||||
end
|
||||
|
||||
def test_loopback?
|
||||
assert_equal(true, IPAddr.new('127.0.0.1').loopback?)
|
||||
assert_equal(true, IPAddr.new('127.127.1.1').loopback?)
|
||||
|
|
Загрузка…
Ссылка в новой задаче