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

ruby-changes:22485

From: naruse <ko1@a...>
Date: Sat, 11 Feb 2012 02:27:35 +0900 (JST)
Subject: [ruby-changes:22485] naruse:r34534 (ruby_1_9_3): merge revision(s) 33485:

naruse	2012-02-11 02:27:22 +0900 (Sat, 11 Feb 2012)

  New Revision: 34534

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

  Log:
    merge revision(s) 33485:
    
    * lib/openssl/buffering.rb: Force multi-byte strings to be treated as
      binary data.
    
    * test/openssl/test_ssl.rb: Add test for it.
    Thanks to Niklas Baumstark for reporting the issue!
    [Ruby 1.9 - Bug #5233] [ruby-core:39120]

  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/ext/openssl/lib/openssl/buffering.rb
    branches/ruby_1_9_3/test/openssl/test_ssl.rb
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 34533)
+++ ruby_1_9_3/ChangeLog	(revision 34534)
@@ -1,3 +1,13 @@
+Sat Feb 11 02:26:51 2012  Martin Bosslet  <Martin.Bosslet@g...>
+
+	* lib/openssl/buffering.rb: Force multi-byte strings to be treated as
+	  binary data.
+	* test/openssl/test_ssl.rb: Add test for it.
+
+	Thanks to Niklas Baumstark for reporting the issue!
+
+	[Ruby 1.9 - Bug #5233] [ruby-core:39120]
+
 Fri Feb 10 17:25:28 2012  Tanaka Akira  <akr@f...>
 
 	* lib/set.rb (SortedSet.setup): remove old_init after initialize
Index: ruby_1_9_3/ext/openssl/lib/openssl/buffering.rb
===================================================================
--- ruby_1_9_3/ext/openssl/lib/openssl/buffering.rb	(revision 34533)
+++ ruby_1_9_3/ext/openssl/lib/openssl/buffering.rb	(revision 34534)
@@ -307,6 +307,7 @@
   def do_write(s)
     @wbuffer = "" unless defined? @wbuffer
     @wbuffer << s
+    @wbuffer.force_encoding(Encoding::BINARY)
     @sync ||= false
     if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)
       remain = idx ? idx + $/.size : @wbuffer.length
@@ -333,7 +334,7 @@
 
   def write(s)
     do_write(s)
-    s.length
+    s.bytesize
   end
 
   ##
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 34533)
+++ ruby_1_9_3/version.h	(revision 34534)
@@ -1,10 +1,10 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 82
+#define RUBY_PATCHLEVEL 83
 
-#define RUBY_RELEASE_DATE "2012-02-10"
+#define RUBY_RELEASE_DATE "2012-02-11"
 #define RUBY_RELEASE_YEAR 2012
 #define RUBY_RELEASE_MONTH 2
-#define RUBY_RELEASE_DAY 10
+#define RUBY_RELEASE_DAY 11
 
 #include "ruby/version.h"
 
Index: ruby_1_9_3/test/openssl/test_ssl.rb
===================================================================
--- ruby_1_9_3/test/openssl/test_ssl.rb	(revision 34533)
+++ ruby_1_9_3/test/openssl/test_ssl.rb	(revision 34534)
@@ -395,6 +395,36 @@
     end
   end
 
+  def test_multibyte_read_write
+    #German a umlaut
+    auml = [%w{ C3 A4 }.join('')].pack('H*')
+    auml.force_encoding(Encoding::UTF_8)
+
+    str = nil
+    num_written = nil
+
+    server_proc = Proc.new {|ctx, ssl|
+      cmp = ssl.read
+      raw_size = cmp.size
+      cmp.force_encoding(Encoding::UTF_8)
+      assert_equal(str, cmp)
+      assert_equal(num_written, raw_size)
+      ssl.close
+    }
+
+    start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :server_proc => server_proc){|server, port|
+      [10, 1000, 100000].each {|i|
+        sock = TCPSocket.new("127.0.0.1", port)
+        ssl = OpenSSL::SSL::SSLSocket.new(sock)
+        ssl.sync_close = true
+        ssl.connect
+        str = auml * i
+        num_written = ssl.write(str)
+        ssl.close
+      }
+    }
+  end
+
   def test_unset_OP_ALL
     ctx_proc = Proc.new { |ctx|
       ctx.options = OpenSSL::SSL::OP_ALL & ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS

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

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