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

ruby-changes:45579

From: kazu <ko1@a...>
Date: Sat, 18 Feb 2017 14:52:23 +0900 (JST)
Subject: [ruby-changes:45579] kazu:r57652 (trunk): {lib, test}/cgi: Specify frozen_string_literal: true.

kazu	2017-02-18 14:52:16 +0900 (Sat, 18 Feb 2017)

  New Revision: 57652

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57652

  Log:
    {lib,test}/cgi: Specify frozen_string_literal: true.

  Modified files:
    trunk/lib/cgi/cookie.rb
    trunk/lib/cgi/core.rb
    trunk/lib/cgi/html.rb
    trunk/lib/cgi/session/pstore.rb
    trunk/lib/cgi/session.rb
    trunk/lib/cgi/util.rb
    trunk/lib/cgi.rb
    trunk/test/cgi/test_cgi_cookie.rb
    trunk/test/cgi/test_cgi_core.rb
    trunk/test/cgi/test_cgi_header.rb
    trunk/test/cgi/test_cgi_modruby.rb
    trunk/test/cgi/test_cgi_multipart.rb
    trunk/test/cgi/test_cgi_session.rb
    trunk/test/cgi/test_cgi_tag_helper.rb
    trunk/test/cgi/test_cgi_util.rb
Index: test/cgi/test_cgi_modruby.rb
===================================================================
--- test/cgi/test_cgi_modruby.rb	(revision 57651)
+++ test/cgi/test_cgi_modruby.rb	(revision 57652)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_modruby.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 require 'test/unit'
 require 'cgi'
 require_relative 'update_env'
Index: test/cgi/test_cgi_multipart.rb
===================================================================
--- test/cgi/test_cgi_multipart.rb	(revision 57651)
+++ test/cgi/test_cgi_multipart.rb	(revision 57652)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_multipart.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 require 'test/unit'
 require 'cgi'
 require 'tempfile'
@@ -33,7 +33,7 @@ class MultiPart https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_multipart.rb#L33
 
   def initialize(boundary=nil)
     @boundary = boundary || create_boundary()
-    @buf = ''
+    @buf = ''.dup
     @buf.force_encoding(::Encoding::ASCII_8BIT) if defined?(::Encoding)
   end
   attr_reader :boundary
@@ -53,7 +53,7 @@ class MultiPart https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_multipart.rb#L53
 
   def close
     buf = @buf
-    @buf = ''
+    @buf = ''.dup
     return buf << "--#{boundary}--\r\n"
   end
 
@@ -202,7 +202,7 @@ class CGIMultipartTest < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_multipart.rb#L202
     @boundary = '----WebKitFormBoundaryAAfvAII+YL9102cX'
     @data = [
       {:name=>'hidden1', :value=>'foobar'},
-      {:name=>'text1',   :value=>"\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A"},
+      {:name=>'text1',   :value=>"\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A".dup},
       {:name=>'file1',   :value=>_read('file1.html'),
        :filename=>'file1.html', :content_type=>'text/html'},
       {:name=>'image1',  :value=>_read('small.png'),
@@ -218,7 +218,7 @@ class CGIMultipartTest < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_multipart.rb#L218
     @boundary = '----WebKitFormBoundaryAAfvAII+YL9102cX'
     @data = [
       {:name=>'hidden1', :value=>'foobar'},
-      {:name=>'text1',   :value=>"\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A"},
+      {:name=>'text1',   :value=>"\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A".dup},
       {:name=>'file1',   :value=>_read('file1.html'),
        :filename=>'file1.html', :content_type=>'text/html'},
       {:name=>'image1',  :value=>_read('large.png'),
@@ -323,7 +323,7 @@ class CGIMultipartTest < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_multipart.rb#L323
     @boundary = '(.|\n)*'
     @data = [
       {:name=>'hidden1', :value=>'foobar'},
-      {:name=>'text1',   :value=>"\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A"},
+      {:name=>'text1',   :value=>"\xE3\x81\x82\xE3\x81\x84\xE3\x81\x86\xE3\x81\x88\xE3\x81\x8A".dup},
       {:name=>'file1',   :value=>_read('file1.html'),
        :filename=>'file1.html', :content_type=>'text/html'},
       {:name=>'image1',  :value=>_read('small.png'),
Index: test/cgi/test_cgi_session.rb
===================================================================
--- test/cgi/test_cgi_session.rb	(revision 57651)
+++ test/cgi/test_cgi_session.rb	(revision 57652)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_session.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 require 'test/unit'
 require 'cgi'
 require 'cgi/session'
@@ -30,7 +30,7 @@ class CGISessionTest < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_session.rb#L30
       'SERVER_PROTOCOL' => 'HTTP/1.1',
     )
     value1="value1"
-    value2="\x8F\xBC\x8D]"
+    value2="\x8F\xBC\x8D]".dup
     value2.force_encoding("SJIS") if defined?(::Encoding)
     cgi = CGI.new
     session = CGI::Session.new(cgi,"tmpdir"=>@session_dir)
@@ -66,7 +66,7 @@ class CGISessionTest < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_session.rb#L66
       'SERVER_PROTOCOL' => 'HTTP/1.1',
     )
     value1="value1"
-    value2="\x8F\xBC\x8D]"
+    value2="\x8F\xBC\x8D]".dup
     value2.force_encoding("SJIS") if defined?(::Encoding)
     cgi = CGI.new
     session = CGI::Session.new(cgi,"tmpdir"=>@session_dir,"database_manager"=>CGI::Session::PStore)
@@ -101,7 +101,7 @@ class CGISessionTest < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_session.rb#L101
       'SERVER_PROTOCOL' => 'HTTP/1.1',
     )
     value1="value1"
-    value2="\x8F\xBC\x8D]"
+    value2="\x8F\xBC\x8D]".dup
     value2.force_encoding("SJIS") if defined?(::Encoding)
     cgi = CGI.new
     session = CGI::Session.new(cgi,"tmpdir"=>@session_dir,"session_id"=>"foo")
@@ -139,7 +139,7 @@ class CGISessionTest < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_session.rb#L139
       'SERVER_PROTOCOL' => 'HTTP/1.1',
     )
     value1="value1"
-    value2="\x8F\xBC\x8D]"
+    value2="\x8F\xBC\x8D]".dup
     value2.force_encoding("SJIS") if defined?(::Encoding)
     cgi = CGI.new
     session = CGI::Session.new(cgi,"tmpdir"=>@session_dir,"session_key"=>"bar")
Index: test/cgi/test_cgi_core.rb
===================================================================
--- test/cgi/test_cgi_core.rb	(revision 57651)
+++ test/cgi/test_cgi_core.rb	(revision 57652)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_core.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 require 'test/unit'
 require 'cgi'
 require 'stringio'
@@ -105,11 +105,11 @@ class CGICoreTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_core.rb#L105
       hash={}
       cgi = CGI.new(:accept_charset=>"UTF-8"){|key,val|hash[key]=val}
       ## cgi[]
-      assert_equal("\xBE\xBE\xB9\xBE".force_encoding("UTF-8"), cgi['str'])
+      assert_equal("\xBE\xBE\xB9\xBE".dup.force_encoding("UTF-8"), cgi['str'])
       ## cgi.params
-      assert_equal(["\xBE\xBE\xB9\xBE".force_encoding("UTF-8")], cgi.params['str'])
+      assert_equal(["\xBE\xBE\xB9\xBE".dup.force_encoding("UTF-8")], cgi.params['str'])
       ## accept-charset error
-      assert_equal({"str"=>"\xBE\xBE\xB9\xBE".force_encoding("UTF-8")},hash)
+      assert_equal({"str"=>"\xBE\xBE\xB9\xBE".dup.force_encoding("UTF-8")},hash)
 
       $stdin.rewind
       assert_raise(CGI::InvalidEncoding) do
@@ -119,9 +119,9 @@ class CGICoreTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_core.rb#L119
       $stdin.rewind
       cgi = CGI.new(:accept_charset=>"EUC-JP")
       ## cgi[]
-      assert_equal("\xBE\xBE\xB9\xBE".force_encoding("EUC-JP"), cgi['str'])
+      assert_equal("\xBE\xBE\xB9\xBE".dup.force_encoding("EUC-JP"), cgi['str'])
       ## cgi.params
-      assert_equal(["\xBE\xBE\xB9\xBE".force_encoding("EUC-JP")], cgi.params['str'])
+      assert_equal(["\xBE\xBE\xB9\xBE".dup.force_encoding("EUC-JP")], cgi.params['str'])
     else
       assert(true)
     end
Index: test/cgi/test_cgi_header.rb
===================================================================
--- test/cgi/test_cgi_header.rb	(revision 57651)
+++ test/cgi/test_cgi_header.rb	(revision 57652)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_header.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 require 'test/unit'
 require 'cgi'
 require 'time'
@@ -58,7 +58,7 @@ class CGIHeaderTest < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_header.rb#L58
       'expires'    => Time.gm(2000, 1, 23, 12, 34, 56),
       'location'   => 'http://www.ruby-lang.org/',
     }
-    expected =  "Status: 302 Found\r\n"
+    expected =  "Status: 302 Found\r\n".dup
     expected << "Server: webrick\r\n"
     expected << "Connection: close\r\n"
     expected << "Content-Type: text/xhtml; charset=utf8\r\n"
@@ -116,7 +116,7 @@ class CGIHeaderTest < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_header.rb#L116
                 CGI::Cookie.new('name'=>'name2', 'value'=>'value2', 'secure'=>true),
               ]
     cgi.instance_variable_set('@output_cookies', cookies)
-    expected =  "Content-Type: text/html; charset=utf8\r\n"
+    expected =  "Content-Type: text/html; charset=utf8\r\n".dup
     expected << "Set-Cookie: name1=abc&123; path=\r\n"
     expected << "Set-Cookie: name2=value2; path=; secure\r\n"
     expected << "\r\n"
@@ -151,7 +151,7 @@ class CGIHeaderTest < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_header.rb#L151
       actual.sub!(date, "Date: DATE_IS_REMOVED\r\n")
     end
     ## assertion
-    expected =  "HTTP/1.1 200 OK\r\n"
+    expected =  "HTTP/1.1 200 OK\r\n".dup
     expected << "Date: DATE_IS_REMOVED\r\n"
     expected << "Server: Apache 2.2.0\r\n"
     expected << "Connection: close\r\n"
@@ -163,10 +163,10 @@ class CGIHeaderTest < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_header.rb#L163
     expected.sub!(/^HTTP\/1.1 200 OK\r\n/, "HTTP/1.1 302 Found\r\n")
     expected.sub!(/\r\n\r\n/, "\r\nlocation: http://www.example.com/\r\n\r\n")
     assert_equal(expected, actual3)
-    expected =  "Content-Type: text/html\r\n"
+    expected =  "Content-Type: text/html\r\n".dup
     expected << "\r\n"
     assert_equal(expected, actual4)
-    expected =  "Status: 302 Found\r\n"
+    expected =  "Status: 302 Found\r\n".dup
     expected << "Content-Type: text/html\r\n"
     expected << "location: http://www.example.com/\r\n"
     expected << "\r\n"
Index: test/cgi/test_cgi_cookie.rb
===================================================================
--- test/cgi/test_cgi_cookie.rb	(revision 57651)
+++ test/cgi/test_cgi_cookie.rb	(revision 57652)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_cookie.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 require 'test/unit'
 require 'cgi'
 require 'stringio'
@@ -15,7 +15,7 @@ class CGICookieTest < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_cookie.rb#L15
       'REQUEST_METHOD' => 'GET',
       'SCRIPT_NAME' => nil,
     )
-    @str1="\xE3\x82\x86\xE3\x82\x93\xE3\x82\x86\xE3\x82\x93"
+    @str1="\xE3\x82\x86\xE3\x82\x93\xE3\x82\x86\xE3\x82\x93".dup
     @str1.force_encoding("UTF-8") if defined?(::Encoding)
   end
 
@@ -39,7 +39,7 @@ class CGICookieTest < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_cookie.rb#L39
 
   def test_cgi_cookie_new_complex
     t = Time.gm(2030, 12, 31, 23, 59, 59)
-    value = ['val1', '&<>"', "\xA5\xE0\xA5\xB9\xA5\xAB"]
+    value = ['val1', '&<>"', "\xA5\xE0\xA5\xB9\xA5\xAB".dup]
     value[2].force_encoding("EUC-JP") if defined?(::Encoding)
     cookie = CGI::Cookie.new('name'=>'name1',
                              'value'=>value,
Index: test/cgi/test_cgi_tag_helper.rb
===================================================================
--- test/cgi/test_cgi_tag_helper.rb	(revision 57651)
+++ test/cgi/test_cgi_tag_helper.rb	(revision 57652)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_tag_helper.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 require 'test/unit'
 require 'cgi'
 require 'stringio'
Index: test/cgi/test_cgi_util.rb
===================================================================
--- test/cgi/test_cgi_util.rb	(revision 57651)
+++ test/cgi/test_cgi_util.rb	(revision 57652)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_util.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 require 'test/unit'
 require 'cgi'
 require 'stringio'
@@ -15,7 +15,7 @@ class CGIUtilTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_util.rb#L15
       'REQUEST_METHOD' => 'GET',
       'SCRIPT_NAME' => nil,
     )
-    @str1="&<>\" \xE3\x82\x86\xE3\x82\x93\xE3\x82\x86\xE3\x82\x93"
+    @str1="&<>\" \xE3\x82\x86\xE3\x82\x93\xE3\x82\x86\xE3\x82\x93".dup
     @str1.force_encoding("UTF-8") if defined?(::Encoding)
   end
 
@@ -31,14 +31,14 @@ class CGIUtilTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_util.rb#L31
 
   def test_cgi_escape_with_invalid_byte_sequence
     assert_nothing_raised(ArgumentError) do
-      assert_equal('%C0%3C%3C', CGI::escape("\xC0\<\<".force_encoding("UTF-8")))
+      assert_equal('%C0%3C%3C', CGI::escape("\xC0\<\<".dup.force_encoding("UTF-8")))
     end
   end
 
   def test_cgi_escape_preserve_encoding
-    assert_equal(Encoding::US_ASCII, CGI::escape("\xC0\<\<".force_encoding("US-ASCII")).encoding)
-    assert_equal(Encoding::ASCII_8BIT, CGI::escape("\xC0\<\<".force_encoding("ASCII-8BIT")).encoding)
-    assert_equal(Encoding::UTF_8, CGI::escape("\xC0\<\<".force_encoding("UTF-8")).encoding)
+    assert_equal(Encoding::US_ASCII, CGI::escape("\xC0\<\<".dup.force_encoding("US-ASCII")).encoding)
+    assert_equal(Encoding::ASCII_8BIT, CGI::escape("\xC0\<\<".dup.force_encoding("ASCII-8BIT")).encoding)
+    assert_equal(Encoding::UTF_8, CGI::escape("\xC0\<\<".dup.force_encoding("UTF-8")).encoding)
   end
 
   def test_cgi_unescape
@@ -51,9 +51,9 @@ class CGIUtilTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_util.rb#L51
   end
 
   def test_cgi_unescape_preserve_encoding
-    assert_equal(Encoding::US_ASCII, CGI::unescape("%C0%3C%3C".force_encoding("US-ASCII")).encoding)
-    assert_equal(Encoding::ASCII_8BIT, CGI::unescape("%C0%3C%3C".force_encoding("ASCII-8BIT")).encoding)
-    assert_equal(Encoding::UTF_8, CGI::unescape("%C0%3C%3C".force_encoding("UTF-8")).encoding)
+    assert_equal(Encoding::US_ASCII, CGI::unescape("%C0%3C%3C".dup.force_encoding("US-ASCII")).encoding)
+    assert_equal(Encoding::ASCII_8BIT, CGI::unescape("%C0%3C%3C".dup.force_encoding("ASCII-8BIT")).encoding)
+    assert_equal(Encoding::UTF_8, CGI::unescape("%C0%3C%3C".dup.force_encoding("UTF-8")).encoding)
   end
 
   def test_cgi_unescape_accept_charset
@@ -72,7 +72,7 @@ class CGIUtilTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_util.rb#L72
   end
 
   def test_cgi_escape_html_duplicated
-    orig = "Ruby".force_encoding("US-ASCII")
+    orig = "Ruby".dup.force_encoding("US-ASCII")
     str = CGI::escapeHTML(orig)
     assert_equal(orig, str)
     assert_not_same(orig, str)
@@ -90,10 +90,10 @@ class CGIUtilTest < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/cgi/test_cgi_util.rb#L90
   end
 
   def test_cgi_escape_html_preserve_tainted
-    assert_not_predicate CGI::escapeHTML("'&\"><"),       :tainted?
-    assert_predicate     CGI::escapeHTML("'&\"><".taint), :tainted?
-    assert_not_predicate CGI::escapeHTML("Ruby"),         :tainted?
-    assert_predicate     CGI::escapeHTML("Ruby".taint),   :tainted?
+    assert_not_predicate CGI::escapeHTML("'&\"><"),           :tainted?
+    assert_predicate     CGI::escapeHTML("'&\"><".dup.taint), :tainted?
+    assert_not_predicate CGI::escapeHTML("Ruby"),             :tainted?
+    assert_predicate     CGI::escapeHTML("Ruby".dup.taint),   :tainted?
   end
 
   def test_cgi_escape_html_dont_freeze
Index: lib/cgi/util.rb
===================================================================
--- lib/cgi/util.rb	(revision 57651)
+++ lib/cgi/util.rb	(revision 57652)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/cgi/util.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 class CGI; module Util; end; extend Util; end
 module CGI::Util
   @@accept_charset="UTF-8" unless defined?(@@accept_charset)
Index: lib/cgi/session/pstore.rb
===================================================================
--- lib/cgi/session/pstore.rb	(revision 57651)
+++ lib/cgi/session/pstore.rb	(revision 57652)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/cgi/session/pstore.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 #
 # cgi/session/pstore.rb - persistent storage of marshalled session data
 #
Index: lib/cgi/session.rb
===================================================================
--- lib/cgi/session.rb	(revision 57651)
+++ lib/cgi/session.rb	(revision 57652)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/cgi/session.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 #
 # cgi/session.rb - session support for cgi scripts
 #
Index: lib/cgi/html.rb
===================================================================
--- lib/cgi/html.rb	(revision 57651)
+++ lib/cgi/html.rb	(revision 57652)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/cgi/html.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 class CGI
   # Base module for HTML-generation mixins.
   #
@@ -26,7 +26,7 @@ class CGI https://github.com/ruby/ruby/blob/trunk/lib/cgi/html.rb#L26
     #   - O EMPTY
     def nOE_element(element, attributes = {})
       attributes={attributes=>nil} if attributes.kind_of?(String)
-      s = "<#{element.upcase}"
+      s = "<#{element.upcase}".dup
       attributes.each do|name, value|
         next unless value
         s << " "
@@ -408,7 +408,7 @@ class CGI https://github.com/ruby/ruby/blob/trunk/lib/cgi/html.rb#L408
       end
       pretty = attributes.delete("PRETTY")
       pretty = "  " if true == pretty
-      buf = ""
+      buf = "".dup
 
       if attributes.has_key?("DOCTYPE")
         if attributes["DOCTYPE"]
Index: lib/cgi/core.rb
===================================================================
--- lib/cgi/core.rb	(revision 57651)
+++ lib/cgi/core.rb	(revision 57652)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/cgi/core.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 #--
 # Methods for generating HTML, parsing CGI-related parameters, and
 # generating HTTP responses.
@@ -182,7 +182,7 @@ class CGI https://github.com/ruby/ruby/blob/trunk/lib/cgi/core.rb#L182
   alias :header :http_header
 
   def _header_for_string(content_type) #:nodoc:
-    buf = ''
+    buf = ''.dup
     if nph?()
       buf << "#{$CGI_ENV['SERVER_PROTOCOL'] || 'HTTP/1.0'} 200 OK#{EOL}"
       buf << "Date: #{CGI.rfc1123_date(Time.now)}#{EOL}"
@@ -198,7 +198,7 @@ class CGI https://github.com/ruby/ruby/blob/trunk/lib/cgi/core.rb#L198
   private :_header_for_string
 
   def _header_for_hash(options)  #:nodoc:
-    buf = ''
+    buf = ''.dup
     ## add charset to option['type']
     options['type'] ||= 'text/html'
     charset = options.delete('charset')
@@ -480,7 +480,7 @@ class CGI https://github.com/ruby/ruby/blob/trunk/lib/cgi/core.rb#L480
       @files = {}
       boundary_rexp = /--#{Regexp.quote(boundary)}(#{EOL}|--)/
       boundary_size = "#{EOL}--#{boundary}#{EOL}".bytesize
-      buf = ''
+      buf = ''.dup
       bufsize = 10 * 1024
       max_count = MAX_MULTIPART_COUNT
       n = 0
@@ -535,12 +535,12 @@ class CGI https://github.com/ruby/ruby/blob/trunk/lib/cgi/core.rb#L535
         body.rewind
         ## original filename
         /Content-Disposition:.* filename=(?:"(.*?)"|([^;\r\n]*))/i.match(head)
-        filename = $1 || $2 || ''
+        filename = $1 || $2 || ''.dup
         filename = CGI.unescape(filename) if unescape_filename?()
         body.instance_variable_set(:@original_filename, filename.taint)
         ## content type
         /Content-Type: (.*)/i.match(head)
-        (content_type = $1 || '').chomp!
+        (content_type = $1 || ''.dup).chomp!
         body.instance_variable_set(:@content_type, content_type.taint)
         ## query parameter name
         /Content-Disposition:.* name=(?:"(.*?)"|([^;\r\n]*))/i.match(head)
@@ -589,7 +589,7 @@ class CGI https://github.com/ruby/ruby/blob/trunk/lib/cgi/core.rb#L589
       else
         begin
           require 'stringio'
-   (... truncated)

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

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