aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@ruby-lang.org>2018-01-25 11:21:47 +0000
committerKazuki Yamaguchi <k@rhe.jp>2021-09-26 19:14:26 +0900
commitb5a4c78afb536eff5b906e066fad5ec57dfb85a8 (patch)
treea62de6dfdfbd9ccd84f1f1669e88780b556d8d3a
parentfef83a1015fc8d1714acf1276178dbd80d1ad55e (diff)
downloadruby-openssl-b5a4c78afb536eff5b906e066fad5ec57dfb85a8.tar.gz
openssl/buffering.rb: no RS when output
[ This is a backport to the 2.1 branch. ] * ext/openssl/lib/openssl/buffering.rb (do_write, puts): output methods should not be affected by the input record separator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e Sync-with-trunk: r62038 (cherry picked from commit 3f6e30e53ce8050375955322e170612e1de099b1)
-rw-r--r--lib/openssl/buffering.rb8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/openssl/buffering.rb b/lib/openssl/buffering.rb
index 935f61f0..1f2b2a7e 100644
--- a/lib/openssl/buffering.rb
+++ b/lib/openssl/buffering.rb
@@ -316,8 +316,8 @@ module OpenSSL::Buffering
@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
+ if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex("\n")
+ remain = idx ? idx + 1 : @wbuffer.size
nwritten = 0
while remain > 0
str = @wbuffer[nwritten,remain]
@@ -409,9 +409,7 @@ module OpenSSL::Buffering
end
args.each{|arg|
s << arg.to_s
- if $/ && /\n\z/ !~ s
- s << "\n"
- end
+ s.sub!(/(?<!\n)\z/, "\n")
}
do_write(s)
nil