[前][次][番号順一覧][スレッド一覧]

ruby-changes:37014

From: akr <ko1@a...>
Date: Fri, 2 Jan 2015 09:10:26 +0900 (JST)
Subject: [ruby-changes:37014] akr:r49095 (trunk): * lib/resolv.rb (Resolv::DNS::Label::Str#==): Check class equality.

akr	2015-01-02 09:10:04 +0900 (Fri, 02 Jan 2015)

  New Revision: 49095

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49095

  Log:
    * lib/resolv.rb (Resolv::DNS::Label::Str#==): Check class equality.
      (Resolv::DNS::Name#initialize): Normalize labels as
      Resolv::DNS::Label::Str objects.

  Modified files:
    trunk/ChangeLog
    trunk/lib/resolv.rb
    trunk/test/resolv/test_dns.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49094)
+++ ChangeLog	(revision 49095)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jan  2 09:08:31 2015  Tanaka Akira  <akr@f...>
+
+	* lib/resolv.rb (Resolv::DNS::Label::Str#==): Check class equality.
+	  (Resolv::DNS::Name#initialize): Normalize labels as
+	  Resolv::DNS::Label::Str objects.
+
 Thu Jan  1 21:41:49 2015  SHIBATA Hiroshi  <shibata.hiroshi@g...>
 
 	* doc/regexp.rdoc: fix regexp docs for whitespace character.
Index: lib/resolv.rb
===================================================================
--- lib/resolv.rb	(revision 49094)
+++ lib/resolv.rb	(revision 49095)
@@ -1185,7 +1185,7 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L1185
         end
 
         def ==(other)
-          return @downcase == other.downcase
+          return self.class == other.class && @downcase == other.downcase
         end
 
         def eql?(other)
@@ -1221,6 +1221,14 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L1221
       end
 
       def initialize(labels, absolute=true) # :nodoc:
+        labels = labels.map {|label|
+          case label
+          when String then Label::Str.new(label)
+          when Label::Str then label
+          else
+            raise ArgumentError, "unexpected label: #{label.inspect}"
+          end
+        }
         @labels = labels
         @absolute = absolute
       end
Index: test/resolv/test_dns.rb
===================================================================
--- test/resolv/test_dns.rb	(revision 49094)
+++ test/resolv/test_dns.rb	(revision 49095)
@@ -190,4 +190,11 @@ class TestResolvDNS < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/resolv/test_dns.rb#L190
     upper = Resolv::DNS::Name.create("Ruby-Lang.org")
     assert_equal(lower, upper, bug10550)
   end
+
+  def test_ipv6_name
+    addr = Resolv::IPv6.new("\0"*16)
+    labels = addr.to_name.to_a
+    expected = (['0'] * 32 + ['ip6', 'arpa']).map {|label| Resolv::DNS::Label::Str.new(label) }
+    assert_equal(expected, labels)
+  end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]