ruby-changes:40662
From: nagachika <ko1@a...>
Date: Wed, 25 Nov 2015 00:49:36 +0900 (JST)
Subject: [ruby-changes:40662] nagachika:r52741 (ruby_2_2): merge revision(s) 52244: [Backport #11513]
nagachika 2015-11-25 00:49:21 +0900 (Wed, 25 Nov 2015) New Revision: 52741 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52741 Log: merge revision(s) 52244: [Backport #11513] * lib/ipaddr.rb, test/test_ipaddr.rb: Reject invalid address contained EOL string. Patch by @kachick [fix GH-942][Bug #11513] Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/lib/ipaddr.rb branches/ruby_2_2/test/test_ipaddr.rb branches/ruby_2_2/version.h Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 52740) +++ ruby_2_2/ChangeLog (revision 52741) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Wed Nov 25 00:47:07 2015 SHIBATA Hiroshi <hsbt@r...> + + * lib/ipaddr.rb, test/test_ipaddr.rb: Reject invalid address contained + EOL string. Patch by @kachick [fix GH-942][Bug #11513] + Wed Nov 25 00:32:44 2015 Nobuyoshi Nakada <nobu@r...> * compile.c (iseq_build_from_ary_body): register cdhash to the Index: ruby_2_2/lib/ipaddr.rb =================================================================== --- ruby_2_2/lib/ipaddr.rb (revision 52740) +++ ruby_2_2/lib/ipaddr.rb (revision 52741) @@ -410,7 +410,7 @@ class IPAddr https://github.com/ruby/ruby/blob/trunk/ruby_2_2/lib/ipaddr.rb#L410 # Set current netmask to given mask. def mask!(mask) if mask.kind_of?(String) - if mask =~ /^\d+$/ + if mask =~ /\A\d+\z/ prefixlen = mask.to_i else m = IPAddr.new(mask) @@ -478,7 +478,7 @@ class IPAddr https://github.com/ruby/ruby/blob/trunk/ruby_2_2/lib/ipaddr.rb#L478 end end prefix, prefixlen = addr.split('/') - if prefix =~ /^\[(.*)\]$/i + if prefix =~ /\A\[(.*)\]\z/i prefix = $1 family = Socket::AF_INET6 end Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 52740) +++ ruby_2_2/version.h (revision 52741) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.4" #define RUBY_RELEASE_DATE "2015-11-25" -#define RUBY_PATCHLEVEL 197 +#define RUBY_PATCHLEVEL 198 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 11 Index: ruby_2_2/test/test_ipaddr.rb =================================================================== --- ruby_2_2/test/test_ipaddr.rb (revision 52740) +++ ruby_2_2/test/test_ipaddr.rb (revision 52741) @@ -69,15 +69,17 @@ class TC_IPAddr < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/test_ipaddr.rb#L69 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") } - assert_raises(IPAddr::InvalidAddressError) { IPAddr.new("fe80::1%fxp0") } - assert_raises(IPAddr::InvalidAddressError) { IPAddr.new("[192.168.1.2]/120") } - assert_raises(IPAddr::InvalidPrefixError) { IPAddr.new("::1/255.255.255.0") } - assert_raises(IPAddr::InvalidPrefixError) { IPAddr.new("::1/129") } - assert_raises(IPAddr::InvalidPrefixError) { IPAddr.new("192.168.0.1/33") } - assert_raises(IPAddr::AddressFamilyError) { IPAddr.new(1) } - assert_raises(IPAddr::AddressFamilyError) { IPAddr.new("::ffff:192.168.1.2/120", Socket::AF_INET) } + assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("192.168.0.256") } + 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("[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/129") } + assert_raise(IPAddr::InvalidPrefixError) { IPAddr.new("192.168.0.1/33") } + assert_raise(IPAddr::AddressFamilyError) { IPAddr.new(1) } + assert_raise(IPAddr::AddressFamilyError) { IPAddr.new("::ffff:192.168.1.2/120", Socket::AF_INET) } end def test_s_new_ntoh @@ -138,14 +140,14 @@ class TC_IPAddr < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/test_ipaddr.rb#L140 def test_ip6_arpa assert_equal("f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.arpa", IPAddr.new("3ffe:505:2::f").ip6_arpa) - assert_raises(IPAddr::InvalidAddressError) { + assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("192.168.2.1").ip6_arpa } end def test_ip6_int assert_equal("f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0.5.0.5.0.e.f.f.3.ip6.int", IPAddr.new("3ffe:505:2::f").ip6_int) - assert_raises(IPAddr::InvalidAddressError) { + assert_raise(IPAddr::InvalidAddressError) { IPAddr.new("192.168.2.1").ip6_int } end Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r52244 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/