* lib/cgi/core.rb: fix multipart form parsing bug. [Bug #3866]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
xibbar 2011-07-09 05:32:19 +00:00
Родитель 57da3d94aa
Коммит 7fd78fad3e
3 изменённых файлов: 18 добавлений и 2 удалений

Просмотреть файл

@ -1,3 +1,7 @@
Sat Jul 9 14:02:20 2011 Takeyuki FUJIOKA <xibbar@ruby-lang.org>
* lib/cgi/core.rb: fix multipart form parsing bug. [Bug #3866]
Sat Jul 9 11:41:03 2011 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
* lib/matrix.rb: Add Vector#normalize [ruby-dev:43829]

Просмотреть файл

@ -557,7 +557,6 @@ class CGI
@files[name]=body
end
## break loop
break if buf.size == 0
break if content_length == -1
end
raise EOFError, "bad boundary end of body part" unless boundary_end =~ /--/

Просмотреть файл

@ -272,7 +272,7 @@ class CGIMultipartTest < Test::Unit::TestCase
ex = assert_raise(EOFError) do
cgi = RUBY_VERSION>="1.9" ? CGI.new(:accept_charset=>"UTF-8") : CGI.new
end
assert_equal("bad boundary end of body part", ex.message)
assert_equal("bad content body", ex.message)
#
_prepare(@data) do |input|
input2 = input.sub(/--(\r\n)?\z/, "")
@ -303,6 +303,19 @@ class CGIMultipartTest < Test::Unit::TestCase
assert_equal('file1.html', cgi['file1'].original_filename)
end
def test_cgi_multipart_boundary_10240 # [Bug #3866]
@boundary = 'AaB03x'
@data = [
{:name=>'file', :value=>"b"*10134,
:filename=>'file.txt', :content_type=>'text/plain'},
{:name=>'foo', :value=>"bar"},
]
_prepare(@data)
cgi = RUBY_VERSION>="1.9" ? CGI.new(:accept_charset=>"UTF-8") : CGI.new
assert_equal(cgi['foo'], 'bar')
assert_equal(cgi['file'].read, 'b'*10134)
end
###
self.instance_methods.each do |method|