diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-05 02:34:17 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-05 02:34:17 +0000 |
commit | 0ba4526d06e16ee496c581d7cf5a9fee801b3109 (patch) | |
tree | a32222b2a628f798712d4a7ed968b3732c791fd1 /lib/cgi | |
parent | 0ba78cb2f79530abf433b008a23778c7468d6af4 (diff) |
* lib/cgi/core.rb: check if Tempfile is defined before use it.
* lib/cgi/core.rb: remove tempfiles only if tempfiles exist
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/cgi')
-rw-r--r-- | lib/cgi/core.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/cgi/core.rb b/lib/cgi/core.rb index a9c9080b76..6a70bb0a70 100644 --- a/lib/cgi/core.rb +++ b/lib/cgi/core.rb @@ -484,7 +484,7 @@ class CGI (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 + tempfiles << body if defined?(Tempfile) && body.kind_of?(Tempfile) class << body if method_defined?(:path) alias local_path path @@ -542,7 +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 + body.unlink if defined?(Tempfile) && body.kind_of?(Tempfile) (params[name] ||= []) << value unless value.valid_encoding? if @accept_charset_error_block @@ -567,7 +567,7 @@ class CGI params.default = [] params ensure - if $! + if $! && tempfiles tempfiles.each {|t| if t.path t.unlink |