ruby-changes:36992
From: nobu <ko1@a...>
Date: Tue, 30 Dec 2014 16:16:23 +0900 (JST)
Subject: [ruby-changes:36992] nobu:r49073 (trunk): resolv.rb: case-insensitive comparison
nobu 2014-12-30 16:16:14 +0900 (Tue, 30 Dec 2014) New Revision: 49073 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49073 Log: resolv.rb: case-insensitive comparison * lib/resolv.rb (Resolv::DNS::Name#==): DNS is case-insensitive, so the comparison should be case-insensitive as well. [ruby-core:66498] [Bug #10550] Modified files: trunk/ChangeLog trunk/lib/resolv.rb trunk/test/resolv/test_dns.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 49072) +++ ChangeLog (revision 49073) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Dec 30 16:16:12 2014 Ben Miller <bmiller@r...> + + * lib/resolv.rb (Resolv::DNS::Name#==): DNS is case-insensitive, so the + comparison should be case-insensitive as well. + [ruby-core:66498] [Bug #10550] + Tue Dec 30 16:03:45 2014 Nobuyoshi Nakada <nobu@r...> * lib/resolv.rb (Resolv::DNS::Name): names with different dots Index: lib/resolv.rb =================================================================== --- lib/resolv.rb (revision 49072) +++ lib/resolv.rb (revision 49073) @@ -1236,8 +1236,8 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L1236 def ==(other) # :nodoc: return false unless Name === other - return @labels.join('.') == other.to_a.join('.') && - @absolute == other.absolute? + return false unless @absolute == other.absolute? + return @labels.join('.').casecmp(other.to_a.join('.')).zero? end alias eql? == # :nodoc: Index: test/resolv/test_dns.rb =================================================================== --- test/resolv/test_dns.rb (revision 49072) +++ test/resolv/test_dns.rb (revision 49073) @@ -183,4 +183,11 @@ class TestResolvDNS < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/resolv/test_dns.rb#L183 name2 = Resolv::DNS::Name.create("ex.ampl.eo.rg") assert_not_equal(name1, name2, "different dots") end + + def test_case_insensitive_name + bug10550 = '[ruby-core:66498] [Bug #10550]' + lower = Resolv::DNS::Name.create("ruby-lang.org") + upper = Resolv::DNS::Name.create("Ruby-Lang.org") + assert_equal(lower, upper, bug10550) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/