mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/ipaddr.rb, test/test_ipaddr.rb: Reject invalid address contained
EOL string. Patch by @kachick [fix GH-942][Bug #11513] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2697fb4990
commit
2cd1f852e1
3 changed files with 9 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Fri Oct 23 16:35:08 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/ipaddr.rb, test/test_ipaddr.rb: Reject invalid address contained
|
||||||
|
EOL string. Patch by @kachick [fix GH-942][Bug #11513]
|
||||||
|
|
||||||
Fri Oct 23 16:03:26 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
Fri Oct 23 16:03:26 2015 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||||
|
|
||||||
* file.c: fix indent style. [fix GH-977]
|
* file.c: fix indent style. [fix GH-977]
|
||||||
|
|
|
@ -410,7 +410,7 @@ class IPAddr
|
||||||
# Set current netmask to given mask.
|
# Set current netmask to given mask.
|
||||||
def mask!(mask)
|
def mask!(mask)
|
||||||
if mask.kind_of?(String)
|
if mask.kind_of?(String)
|
||||||
if mask =~ /^\d+$/
|
if mask =~ /\A\d+\z/
|
||||||
prefixlen = mask.to_i
|
prefixlen = mask.to_i
|
||||||
else
|
else
|
||||||
m = IPAddr.new(mask)
|
m = IPAddr.new(mask)
|
||||||
|
@ -478,7 +478,7 @@ class IPAddr
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
prefix, prefixlen = addr.split('/')
|
prefix, prefixlen = addr.split('/')
|
||||||
if prefix =~ /^\[(.*)\]$/i
|
if prefix =~ /\A\[(.*)\]\z/i
|
||||||
prefix = $1
|
prefix = $1
|
||||||
family = Socket::AF_INET6
|
family = Socket::AF_INET6
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,6 +73,8 @@ class TC_IPAddr < Test::Unit::TestCase
|
||||||
assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("192.168.0.011") }
|
assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("192.168.0.011") }
|
||||||
assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("fe80::1%fxp0") }
|
assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("fe80::1%fxp0") }
|
||||||
assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("[192.168.1.2]/120") }
|
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::InvalidPrefixError) { IPAddr.new("::1/255.255.255.0") }
|
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("::1/129") }
|
||||||
assert_raise(IPAddr::InvalidPrefixError) { IPAddr.new("192.168.0.1/33") }
|
assert_raise(IPAddr::InvalidPrefixError) { IPAddr.new("192.168.0.1/33") }
|
||||||
|
|
Loading…
Reference in a new issue