ruby-changes:36453
From: tenderlove <ko1@a...>
Date: Sat, 22 Nov 2014 05:04:34 +0900 (JST)
Subject: [ruby-changes:36453] tenderlove:r48534 (trunk): * lib/resolv.rb: fall back if canonicalization fails.
tenderlove 2014-11-22 05:04:27 +0900 (Sat, 22 Nov 2014) New Revision: 48534 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48534 Log: * lib/resolv.rb: fall back if canonicalization fails. Thanks Vit Ondruch for the patch! [ruby-core:65836] * test/resolv/test_dns.rb: test for patch Modified files: trunk/ChangeLog trunk/lib/resolv.rb trunk/test/resolv/test_dns.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 48533) +++ ChangeLog (revision 48534) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Nov 21 11:58:58 2014 Aaron Patterson <aaron@t...> + + * lib/resolv.rb: fall back if canonicalization fails. + Thanks Vit Ondruch for the patch! [ruby-core:65836] + + * test/resolv/test_dns.rb: test for patch + Sat Nov 22 01:11:53 2014 Nobuyoshi Nakada <nobu@r...> * object.c (rb_mod_const_get, rb_mod_const_defined): ditto. Index: lib/resolv.rb =================================================================== --- lib/resolv.rb (revision 48533) +++ lib/resolv.rb (revision 48534) @@ -1066,6 +1066,10 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L1066 candidates = [] end candidates.concat(@search.map {|domain| Name.new(name.to_a + domain)}) + fname = Name.create("#{name}.") + if !candidates.include?(fname) + candidates << fname + end end return candidates end Index: test/resolv/test_dns.rb =================================================================== --- test/resolv/test_dns.rb (revision 48533) +++ test/resolv/test_dns.rb (revision 48534) @@ -23,6 +23,20 @@ class TestResolvDNS < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/resolv/test_dns.rb#L23 end end + # [ruby-core:65836] + def test_resolve_with_2_ndots + conf = Resolv::DNS::Config.new :nameserver => ['127.0.0.1'], :ndots => 2 + assert conf.single? + + candidates = [] + conf.resolv('example.com') { |candidate, *args| + candidates << candidate + raise Resolv::DNS::Config::NXDomain + } + n = Resolv::DNS::Name.create 'example.com.' + assert_equal n, candidates.last + end + def test_query_ipv4_address begin OpenSSL -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/