Skip to content

Commit

Permalink
try to show fail described in rack#1308
Browse files Browse the repository at this point in the history
  • Loading branch information
aiomaster committed Oct 25, 2018
1 parent 5559676 commit e95568c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/spec_multipart.rb
Expand Up @@ -6,6 +6,7 @@
require 'rack/multipart/parser'
require 'rack/utils'
require 'rack/mock'
require 'timeout'

describe Rack::Multipart do
def multipart_fixture(name, boundary = "AaB03x")
Expand Down Expand Up @@ -146,6 +147,29 @@ def rd.rewind; end
wr.close
end

it "parse strange multipart pdf" do
boundary = '---------------------------932620571087722842402766118'

data = StringIO.new
data.write("--#{boundary}")
data.write("\r\n")
data.write('Content-Disposition: form-data; name="a"; filename="a.pdf"')
data.write("\r\n")
data.write("Content-Type:application/pdf\r\n")
data.write("\r\n")
data.write(File.read('test/test_1308.pdf'))
data.write("--#{boundary}--\r\n")

fixture = {
"CONTENT_TYPE" => "multipart/form-data; boundary=#{boundary}",
"CONTENT_LENGTH" => data.length.to_s,
:input => data,
}

env = Rack::MockRequest.env_for '/', fixture
Timeout::timeout(10) { Rack::Multipart.parse_multipart(env) }
end

it 'raises an EOF error on content-length mistmatch' do
env = Rack::MockRequest.env_for("/", multipart_fixture(:empty))
env['rack.input'] = StringIO.new
Expand Down
Binary file added test/test_1308.pdf
Binary file not shown.

0 comments on commit e95568c

Please sign in to comment.