File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ def allowed_methods
3838 def method_override_param ( req )
3939 req . POST [ METHOD_OVERRIDE_PARAM_KEY ]
4040 rescue Utils ::InvalidParameterError , Utils ::ParameterTypeError
41+ req . env [ "rack.errors" ] . puts "Invalid or incomplete POST params"
42+ rescue EOFError
43+ req . env [ "rack.errors" ] . puts "Bad request content body"
4144 end
4245 end
4346end
Original file line number Diff line number Diff line change @@ -65,14 +65,27 @@ def app
6565 "CONTENT_TYPE" => "multipart/form-data, boundary=AaB03x" ,
6666 "CONTENT_LENGTH" => input . size . to_s ,
6767 :method => "POST" , :input => input )
68- begin
69- app . call env
70- rescue EOFError
71- end
68+ app . call env
7269
7370 env [ "REQUEST_METHOD" ] . should . equal "POST"
7471 end
7572
73+ should "write error to RACK_ERRORS when given invalid multipart form data" do
74+ input = <<EOF
75+ --AaB03x\r
76+ content-disposition: form-data; name="huge"; filename="huge"\r
77+ EOF
78+ env = Rack ::MockRequest . env_for ( "/" ,
79+ "CONTENT_TYPE" => "multipart/form-data, boundary=AaB03x" ,
80+ "CONTENT_LENGTH" => input . size . to_s ,
81+ "rack.errors" => StringIO . new ,
82+ :method => "POST" , :input => input )
83+ Rack ::MethodOverride . new ( proc { [ 200 , { "Content-Type" => "text/plain" } , [ ] ] } ) . call env
84+
85+ env [ "rack.errors" ] . rewind
86+ env [ "rack.errors" ] . read . should =~ /Bad request content body/
87+ end
88+
7689 should "not modify REQUEST_METHOD for POST requests when the params are unparseable" do
7790 env = Rack ::MockRequest . env_for ( "/" , :method => "POST" , :input => "(%bad-params%)" )
7891 app . call env
You can’t perform that action at this time.
0 commit comments