diff --git a/lib/rack/auth/digest/params.rb b/lib/rack/auth/digest/params.rb index 2b226e628..3ac615c8f 100644 --- a/lib/rack/auth/digest/params.rb +++ b/lib/rack/auth/digest/params.rb @@ -38,12 +38,12 @@ def []=(k, v) def to_s map do |k, v| - "#{k}=" << (UNQUOTED.include?(k) ? v.to_s : quote(v)) + "#{k}=#{(UNQUOTED.include?(k) ? v.to_s : quote(v))}" end.join(', ') end def quote(str) # From WEBrick::HTTPUtils - '"' << str.gsub(/[\\\"]/o, "\\\1") << '"' + '"' + str.gsub(/[\\\"]/o, "\\\1") + '"' end end diff --git a/lib/rack/multipart/parser.rb b/lib/rack/multipart/parser.rb index e2e821ace..af8704137 100644 --- a/lib/rack/multipart/parser.rb +++ b/lib/rack/multipart/parser.rb @@ -252,7 +252,7 @@ def handle_mime_head filename = get_filename(head) if name.nil? || name.empty? - name = filename || "#{content_type || TEXT_PLAIN}[]" + name = filename || "#{content_type || TEXT_PLAIN}[]".dup end @collector.on_mime_head @mime_index, head, filename, content_type, name diff --git a/lib/rack/request.rb b/lib/rack/request.rb index 2a00de704..cbe6b38db 100644 --- a/lib/rack/request.rb +++ b/lib/rack/request.rb @@ -391,7 +391,7 @@ def delete_param(k) def base_url url = "#{scheme}://#{host}" - url << ":#{port}" if port != DEFAULT_PORTS[scheme] + url = "#{url}:#{port}" if port != DEFAULT_PORTS[scheme] url end diff --git a/lib/rack/rewindable_input.rb b/lib/rack/rewindable_input.rb index dd6b78439..f14b8f592 100644 --- a/lib/rack/rewindable_input.rb +++ b/lib/rack/rewindable_input.rb @@ -72,7 +72,7 @@ def make_rewindable @unlinked = true end - buffer = "" + buffer = "".dup while @io.read(1024 * 4, buffer) entire_buffer_written_out = false while !entire_buffer_written_out diff --git a/lib/rack/show_exceptions.rb b/lib/rack/show_exceptions.rb index ca86b2b2a..6d7c52538 100644 --- a/lib/rack/show_exceptions.rb +++ b/lib/rack/show_exceptions.rb @@ -55,7 +55,7 @@ def accepts_html?(env) private :accepts_html? def dump_exception(exception) - string = "#{exception.class}: #{exception.message}\n" + string = "#{exception.class}: #{exception.message}\n".dup string << exception.backtrace.map { |l| "\t#{l}" }.join("\n") string end diff --git a/test/spec_chunked.rb b/test/spec_chunked.rb index dc6e8c9d2..a56db8b7e 100644 --- a/test/spec_chunked.rb +++ b/test/spec_chunked.rb @@ -42,8 +42,8 @@ def chunked(app) response.headers.wont_include 'Content-Length' response.headers['Transfer-Encoding'].must_equal 'chunked' response.body.encoding.to_s.must_equal "ASCII-8BIT" - response.body.must_equal "c\r\n\xFE\xFFH\x00e\x00l\x00l\x00o\x00\r\n2\r\n \x00\r\na\r\nW\x00o\x00r\x00l\x00d\x00\r\n0\r\n\r\n".force_encoding("BINARY") - response.body.must_equal "c\r\n\xFE\xFFH\x00e\x00l\x00l\x00o\x00\r\n2\r\n \x00\r\na\r\nW\x00o\x00r\x00l\x00d\x00\r\n0\r\n\r\n".force_encoding(Encoding::BINARY) + response.body.must_equal "c\r\n\xFE\xFFH\x00e\x00l\x00l\x00o\x00\r\n2\r\n \x00\r\na\r\nW\x00o\x00r\x00l\x00d\x00\r\n0\r\n\r\n".dup.force_encoding("BINARY") + response.body.must_equal "c\r\n\xFE\xFFH\x00e\x00l\x00l\x00o\x00\r\n2\r\n \x00\r\na\r\nW\x00o\x00r\x00l\x00d\x00\r\n0\r\n\r\n".dup.force_encoding(Encoding::BINARY) end it 'not modify response when Content-Length header present' do diff --git a/test/spec_deflater.rb b/test/spec_deflater.rb index 0f27c859f..9c2ec08ba 100644 --- a/test/spec_deflater.rb +++ b/test/spec_deflater.rb @@ -57,7 +57,7 @@ def verify(expected_status, expected_body, accept_encoding, options = {}, &block # verify body unless options['skip_body_verify'] - body_text = '' + body_text = ''.dup body.each { |part| body_text << part } deflated_body = case expected_encoding diff --git a/test/spec_directory.rb b/test/spec_directory.rb index 42bdea9f6..10584f377 100644 --- a/test/spec_directory.rb +++ b/test/spec_directory.rb @@ -27,7 +27,7 @@ def setup assert_equal 200, status - str = '' + str = ''.dup body.each { |x| str << x } assert_match "foo+bar", str end @@ -113,7 +113,7 @@ def setup assert_equal 200, status - str = '' + str = ''.dup body.each { |x| str << x } assert_match "/foo%20bar/omg%20omg.txt", str end diff --git a/test/spec_file.rb b/test/spec_file.rb index 48c0ab909..4eeb3ca04 100644 --- a/test/spec_file.rb +++ b/test/spec_file.rb @@ -19,7 +19,7 @@ def file(*args) assert_equal 200, status - str = '' + str = ''.dup body.each { |x| str << x } assert_match "hello world", str end diff --git a/test/spec_lint.rb b/test/spec_lint.rb index d99c1aa31..c7b195f96 100644 --- a/test/spec_lint.rb +++ b/test/spec_lint.rb @@ -483,7 +483,7 @@ def rewind end def assert_lint(*args) - hello_str = "hello world" + hello_str = "hello world".dup hello_str.force_encoding(Encoding::ASCII_8BIT) Rack::Lint.new(lambda { |env| @@ -498,8 +498,8 @@ def assert_lint(*args) assert_lint 0 assert_lint 1 assert_lint nil - assert_lint nil, '' - assert_lint 1, '' + assert_lint nil, ''.dup + assert_lint 1, ''.dup end end diff --git a/test/spec_multipart.rb b/test/spec_multipart.rb index 40bab4cd6..980600c92 100644 --- a/test/spec_multipart.rb +++ b/test/spec_multipart.rb @@ -201,7 +201,7 @@ def initialize(*) it "parse multipart upload file using custom tempfile class" do env = Rack::MockRequest.env_for("/", multipart_fixture(:text)) - my_tempfile = "" + my_tempfile = "".dup env['rack.multipart.tempfile_factory'] = lambda { |filename, content_type| my_tempfile } params = Rack::Multipart.parse_multipart(env) params["files"][:tempfile].object_id.must_equal my_tempfile.object_id @@ -683,7 +683,7 @@ def initialize(*) it "fallback to content-type for name" do rack_logo = File.read(multipart_file("rack-logo.png")) - data = <<-EOF + data = <<-EOF.dup --AaB03x\r Content-Type: text/plain\r \r @@ -702,7 +702,7 @@ def initialize(*) options = { "CONTENT_TYPE" => "multipart/related; boundary=AaB03x", "CONTENT_LENGTH" => data.bytesize.to_s, - :input => StringIO.new(data) + :input => StringIO.new(data.dup) } env = Rack::MockRequest.env_for("/", options) params = Rack::Multipart.parse_multipart(env) diff --git a/test/spec_request.rb b/test/spec_request.rb index bdad68fa7..82343c0cc 100644 --- a/test/spec_request.rb +++ b/test/spec_request.rb @@ -1106,7 +1106,7 @@ def initialize(*) [200, {"Content-Type" => "text/html", "Content-Length" => size.to_s}, [content]] } - input = <