mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/ipaddr] Raise if extra slashes follow
https://bugs.ruby-lang.org/issues/15832 https://github.com/ruby/ipaddr/commit/de9805d6fa
This commit is contained in:
parent
54ee22be53
commit
38da84296c
2 changed files with 2 additions and 1 deletions
|
@ -566,7 +566,7 @@ class IPAddr
|
|||
raise AddressFamilyError, "unsupported address family: #{family}"
|
||||
end
|
||||
end
|
||||
prefix, prefixlen = addr.split('/')
|
||||
prefix, prefixlen = addr.split('/', 2)
|
||||
if prefix =~ /\A\[(.*)\]\z/i
|
||||
prefix = $1
|
||||
family = Socket::AF_INET6
|
||||
|
|
|
@ -91,6 +91,7 @@ class TC_IPAddr < Test::Unit::TestCase
|
|||
assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("[192.168.1.2]/120") }
|
||||
assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("[2001:200:300::]\nINVALID") }
|
||||
assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("192.168.0.1/32\nINVALID") }
|
||||
assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("192.168.0.1/32/20") }
|
||||
assert_raise(IPAddr::InvalidPrefixError) { IPAddr.new("::1/255.255.255.0") }
|
||||
assert_raise(IPAddr::InvalidPrefixError) { IPAddr.new("::1/129") }
|
||||
assert_raise(IPAddr::InvalidPrefixError) { IPAddr.new("192.168.0.1/33") }
|
||||
|
|
Loading…
Reference in a new issue