about summary refs log tree commit homepage
path: root/lib/yahns/max_body/wrapper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/yahns/max_body/wrapper.rb')
-rw-r--r--lib/yahns/max_body/wrapper.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/yahns/max_body/wrapper.rb b/lib/yahns/max_body/wrapper.rb
index e618568..b8ed8a6 100644
--- a/lib/yahns/max_body/wrapper.rb
+++ b/lib/yahns/max_body/wrapper.rb
@@ -1,11 +1,14 @@
 # -*- encoding: binary -*-
 # Copyright (C) 2013-2015 all contributors <yahns-public@yhbt.net>
 # License: GPLv2 or later (https://www.gnu.org/licenses/gpl-2.0.txt)
+# frozen_string_literal: true
 #
 # This is only used for chunked request bodies, which are rare
 class Yahns::MaxBody::Wrapper # :nodoc:
   def initialize(rack_input, limit)
-    @input, @limit, @rbuf = rack_input, limit, ''
+    @input = rack_input
+    @limit = limit
+    @rbuf = ''.dup
   end
 
   def each
@@ -16,7 +19,7 @@ class Yahns::MaxBody::Wrapper # :nodoc:
 
   # chunked encoding means this method behaves more like readpartial,
   # since Rack does not support a method named "readpartial"
-  def read(length = nil, rv = '')
+  def read(length = nil, rv = ''.dup)
     if length
       if length <= @rbuf.size
         length < 0 and raise ArgumentError, "negative length #{length} given"
@@ -53,7 +56,7 @@ class Yahns::MaxBody::Wrapper # :nodoc:
     end while true
   end
 
-  def checked_read(length = 16384, buf = '')
+  def checked_read(length = 16384, buf = ''.dup)
     if @input.read(length, buf)
       throw :yahns_EFBIG if ((@limit -= buf.size) < 0)
       return buf
@@ -62,7 +65,7 @@ class Yahns::MaxBody::Wrapper # :nodoc:
 
   def read_all
     rv = @rbuf.slice!(0, @rbuf.size)
-    tmp = ''
+    tmp = ''.dup
     while checked_read(16384, tmp)
       rv << tmp
     end