mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/resolv.rb (Resolv::IPv4::Regex): make it only accept 0 to 255.
[ruby-core:29501] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e70a308c75
commit
20a6e94e47
3 changed files with 26 additions and 1 deletions
16
test/resolv/test_addr.rb
Normal file
16
test/resolv/test_addr.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
require 'test/unit'
|
||||
require 'resolv'
|
||||
require 'socket'
|
||||
|
||||
class TestResolvAddr < Test::Unit::TestCase
|
||||
def test_invalid_ipv4_address
|
||||
assert_not_match(Resolv::IPv4::Regex, "1.2.3.256", "[ruby-core:29501]")
|
||||
1000.times {|i|
|
||||
if i < 256
|
||||
assert_match(Resolv::IPv4::Regex, "#{i}.#{i}.#{i}.#{i}")
|
||||
else
|
||||
assert_not_match(Resolv::IPv4::Regex, "#{i}.#{i}.#{i}.#{i}")
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue