summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-30 07:16:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-30 07:16:14 +0000
commit69a7bb31f917bd68d78460216aa2ef274428790e (patch)
treefd66f4aafba8736937b0421153cf48570214c76c
parent1441d9da990e432ac2d08389f7973684316d8664 (diff)
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--lib/resolv.rb4
-rw-r--r--test/resolv/test_dns.rb7
3 files changed, 15 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 4452bb2..1f02c60 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Dec 30 16:16:12 2014 Ben Miller <bmiller@rackspace.com>
+
+ * 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@ruby-lang.org>
* lib/resolv.rb (Resolv::DNS::Name): names with different dots
diff --git a/lib/resolv.rb b/lib/resolv.rb
index f6971bf..5a4c0eb 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -1236,8 +1236,8 @@ class Resolv
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:
diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb
index 47cc314..8e54dd7 100644
--- a/test/resolv/test_dns.rb
+++ b/test/resolv/test_dns.rb
@@ -183,4 +183,11 @@ class TestResolvDNS < Test::Unit::TestCase
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