diff options
author | xibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-05 00:57:45 +0000 |
---|---|---|
committer | xibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-05 00:57:45 +0000 |
commit | 1362d81a22ab179c1286a61b8d5a54e59784458e (patch) | |
tree | 44eec54663cd2129323dd1e2e61d9313b39ef571 /lib | |
parent | d5528ec3580dba09ebbda819c7b10e25d5af5981 (diff) | |
download | ruby-1362d81a22ab179c1286a61b8d5a54e59784458e.tar.gz |
Mon Nov 5 09:55:05 2012 Takeyuki FUJIOKA <xibbar@ruby-lang.org>
* lib/cgi/core.rb: remove tempfile more early.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cgi/core.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/cgi/core.rb b/lib/cgi/core.rb index 63ab3c81d6..a9c9080b76 100644 --- a/lib/cgi/core.rb +++ b/lib/cgi/core.rb @@ -479,10 +479,12 @@ class CGI bufsize = 10 * 1024 max_count = MAX_MULTIPART_COUNT n = 0 + tempfiles = [] while true (n += 1) < max_count or raise StandardError.new("too many parameters.") ## create body (StringIO or Tempfile) body = create_body(bufsize < content_length) + tempfiles << body if body.kind_of? Tempfile class << body if method_defined?(:path) alias local_path path @@ -540,6 +542,7 @@ class CGI name = $1 || $2 || '' if body.original_filename.empty? value=body.read.dup.force_encoding(@accept_charset) + body.unlink if body.kind_of? Tempfile (params[name] ||= []) << value unless value.valid_encoding? if @accept_charset_error_block @@ -563,6 +566,14 @@ class CGI raise EOFError, "bad boundary end of body part" unless boundary_end =~ /--/ params.default = [] params + ensure + if $! + tempfiles.each {|t| + if t.path + t.unlink + end + } + end end # read_multipart private :read_multipart def create_body(is_large) #:nodoc: |