1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/cgi/core.rb (read_multipart): file's encoding is ascii-8bit

from file field of multipart form.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
xibbar 2008-10-20 12:29:29 +00:00
parent 71b832dd8e
commit 225d2af65a
2 changed files with 11 additions and 6 deletions

View file

@ -1,3 +1,8 @@
Mon Oct 20 21:19:00 2008 Takeyuki FUJIOKA <xibbar@ruby-lang.org>
* lib/cgi/core.rb (read_multipart): file's encoding is ascii-8bit
from file field of multipart form.
Mon Oct 20 20:16:25 2008 Yukihiro Matsumoto <matz@ruby-lang.org> Mon Oct 20 20:16:25 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/zlib/zlib.c (Init_zlib): add getbyte as an alias to getc. * ext/zlib/zlib.c (Init_zlib): add getbyte as an alias to getc.

View file

@ -495,14 +495,14 @@ class CGI
def create_body(is_large) #:nodoc: def create_body(is_large) #:nodoc:
if is_large if is_large
require 'tempfile' require 'tempfile'
body = Tempfile.new('CGI') body = Tempfile.new('CGI', encoding: "ascii-8bit")
else else
begin begin
require 'stringio' require 'stringio'
body = StringIO.new body = StringIO.new("".force_encoding("ascii-8bit"))
rescue LoadError rescue LoadError
require 'tempfile' require 'tempfile'
body = Tempfile.new('CGI') body = Tempfile.new('CGI', encoding: "ascii-8bit")
end end
end end
body.binmode if defined? body.binmode body.binmode if defined? body.binmode
@ -568,7 +568,7 @@ class CGI
read_from_cmdline read_from_cmdline
end.dup.force_encoding(@accept_charset) end.dup.force_encoding(@accept_charset)
) )
unless @accept_charset=="ASCII-8BIT" || @accept_charset==Encoding::ASCII_8BIT unless @accept_charset=~/ASCII-8BIT/i || @accept_charset==Encoding::ASCII_8BIT
@params.each do |key,values| @params.each do |key,values|
values.each do |value| values.each do |value|
unless value.valid_encoding? unless value.valid_encoding?
@ -603,9 +603,9 @@ class CGI
if value if value
return value return value
elsif defined? StringIO elsif defined? StringIO
StringIO.new("") StringIO.new("".force_encoding("ascii-8bit"))
else else
Tempfile.new("CGI") Tempfile.new("CGI",encoding:"ascii-8bit")
end end
else else
str = if value then value.dup else "" end str = if value then value.dup else "" end