mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1a2f635761
commit
65ca601ba6
3 changed files with 42 additions and 1 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
Thu Oct 20 06:55:32 2011 Martin Bosslet <Martin.Bosslet@googlemail.com>
|
||||||
|
|
||||||
|
* 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]
|
||||||
|
|
||||||
Wed Oct 19 17:06:54 2011 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Wed Oct 19 17:06:54 2011 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* version.h (RUBY_VERSION): finally declare start of 2.0 work!
|
* version.h (RUBY_VERSION): finally declare start of 2.0 work!
|
||||||
|
|
|
@ -307,6 +307,7 @@ module OpenSSL::Buffering
|
||||||
def do_write(s)
|
def do_write(s)
|
||||||
@wbuffer = "" unless defined? @wbuffer
|
@wbuffer = "" unless defined? @wbuffer
|
||||||
@wbuffer << s
|
@wbuffer << s
|
||||||
|
@wbuffer.force_encoding(Encoding::BINARY)
|
||||||
@sync ||= false
|
@sync ||= false
|
||||||
if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)
|
if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)
|
||||||
remain = idx ? idx + $/.size : @wbuffer.length
|
remain = idx ? idx + $/.size : @wbuffer.length
|
||||||
|
@ -333,7 +334,7 @@ module OpenSSL::Buffering
|
||||||
|
|
||||||
def write(s)
|
def write(s)
|
||||||
do_write(s)
|
do_write(s)
|
||||||
s.length
|
s.bytesize
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -394,6 +394,36 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue