From 4b9c90a29d5edbf026920055bf16c76f7616a44a Mon Sep 17 00:00:00 2001 From: Sam Phillips Date: Wed, 4 Apr 2018 14:28:59 -0400 Subject: [PATCH] Add backport fix --- lib/rack/request.rb | 2 +- test/spec_request.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/rack/request.rb b/lib/rack/request.rb index 5778bf296..db81909fb 100644 --- a/lib/rack/request.rb +++ b/lib/rack/request.rb @@ -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 @@ -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 {} diff --git a/test/spec_request.rb b/test/spec_request.rb index f94579557..b7ac42f74 100644 --- a/test/spec_request.rb +++ b/test/spec_request.rb @@ -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 = < "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