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

ruby-changes:41291

From: normal <ko1@a...>
Date: Tue, 29 Dec 2015 05:31:18 +0900 (JST)
Subject: [ruby-changes:41291] normal:r53363 (trunk): Resolv::IPv6.create: avoid modifying frozen string literal

normal	2015-12-29 05:31:10 +0900 (Tue, 29 Dec 2015)

  New Revision: 53363

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

  Log:
    Resolv::IPv6.create: avoid modifying frozen string literal
    
    * lib/resolv.rb (Resolv::IPv6.create): avoid modifying frozen
    * test/resolv/test_dns.rb (test_ipv6_create): test for above
      [Bug #11910] [ruby-core:72559]

  Modified files:
    trunk/ChangeLog
    trunk/lib/resolv.rb
    trunk/test/resolv/test_dns.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53362)
+++ ChangeLog	(revision 53363)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Dec 29 05:30:30 2015  Eric Wong  <e@8...>
+
+	* lib/resolv.rb (Resolv::IPv6.create): avoid modifying frozen
+	* test/resolv/test_dns.rb (test_ipv6_create): test for above
+	  [Bug #11910] [ruby-core:72559]
+
 Mon Dec 28 14:55:57 2015  Kuniaki IGARASHI  <igaiga@g...>
 
 	* test/ruby/test_string.rb (TestString#test_rstrip_bang): Add test
Index: lib/resolv.rb
===================================================================
--- lib/resolv.rb	(revision 53362)
+++ lib/resolv.rb	(revision 53363)
@@ -2451,14 +2451,14 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L2451
       when IPv6
         return arg
       when String
-        address = ''
+        address = ''.b
         if Regex_8Hex =~ arg
           arg.scan(/[0-9A-Fa-f]+/) {|hex| address << [hex.hex].pack('n')}
         elsif Regex_CompressedHex =~ arg
           prefix = $1
           suffix = $2
-          a1 = ''
-          a2 = ''
+          a1 = ''.b
+          a2 = ''.b
           prefix.scan(/[0-9A-Fa-f]+/) {|hex| a1 << [hex.hex].pack('n')}
           suffix.scan(/[0-9A-Fa-f]+/) {|hex| a2 << [hex.hex].pack('n')}
           omitlen = 16 - a1.length - a2.length
@@ -2474,8 +2474,8 @@ class Resolv https://github.com/ruby/ruby/blob/trunk/lib/resolv.rb#L2474
         elsif Regex_CompressedHex4Dec =~ arg
           prefix, suffix, a, b, c, d = $1, $2, $3.to_i, $4.to_i, $5.to_i, $6.to_i
           if (0..255) === a && (0..255) === b && (0..255) === c && (0..255) === d
-            a1 = ''
-            a2 = ''
+            a1 = ''.b
+            a2 = ''.b
             prefix.scan(/[0-9A-Fa-f]+/) {|hex| a1 << [hex.hex].pack('n')}
             suffix.scan(/[0-9A-Fa-f]+/) {|hex| a2 << [hex.hex].pack('n')}
             omitlen = 12 - a1.length - a2.length
Index: test/resolv/test_dns.rb
===================================================================
--- test/resolv/test_dns.rb	(revision 53362)
+++ test/resolv/test_dns.rb	(revision 53363)
@@ -199,6 +199,12 @@ class TestResolvDNS < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/resolv/test_dns.rb#L199
     assert_equal(expected, labels)
   end
 
+  def test_ipv6_create
+    ref = '[Bug #11910] [ruby-core:72559]'
+    assert_instance_of Resolv::IPv6, Resolv::IPv6.create('::1')
+    assert_instance_of Resolv::IPv6, Resolv::IPv6.create('::1:127.0.0.1')
+  end
+
   def test_too_big_label_address
     n = 2000
     m = Resolv::DNS::Message::MessageEncoder.new {|msg|

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

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