Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Add backport fix #1

Open
wants to merge 1 commit into
base: rack-1.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rack/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ def POST
elsif @env["rack.request.form_input"].eql? @env["rack.input"]
@env["rack.request.form_hash"]
elsif form_data? || parseable_data?
@env["rack.request.form_input"] = @env["rack.input"]
unless @env["rack.request.form_hash"] = parse_multipart(env)
form_vars = @env["rack.input"].read

Expand All @@ -210,6 +209,7 @@ def POST

@env["rack.input"].rewind
end
@env["rack.request.form_input"] = @env["rack.input"]
@env["rack.request.form_hash"]
else
{}
Expand Down
14 changes: 14 additions & 0 deletions test/spec_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,20 @@
lambda{ req.POST }.should.not.raise("input re-processed!")
end

should "consistently raise EOFError on bad multipart form data" do
input = <<EOF
--AaB03x\r
content-disposition: form-data; name="huge"; filename="huge"\r
EOF
req = Rack::Request.new Rack::MockRequest.env_for("/",
"CONTENT_TYPE" => "multipart/form-data, boundary=AaB03x",
"CONTENT_LENGTH" => input.size,
:input => input)

lambda { req.POST }.should.raise(EOFError)
lambda { req.POST }.should.raise(EOFError)
end

should "conform to the Rack spec" do
app = lambda { |env|
content = Rack::Request.new(env).POST["file"].inspect
Expand Down