File tree 2 files changed +20
-4
lines changed 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ def allowed_methods
38
38
def method_override_param ( req )
39
39
req . POST [ METHOD_OVERRIDE_PARAM_KEY ]
40
40
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"
41
44
end
42
45
end
43
46
end
Original file line number Diff line number Diff line change @@ -65,14 +65,27 @@ def app
65
65
"CONTENT_TYPE" => "multipart/form-data, boundary=AaB03x" ,
66
66
"CONTENT_LENGTH" => input . size . to_s ,
67
67
:method => "POST" , :input => input )
68
- begin
69
- app . call env
70
- rescue EOFError
71
- end
68
+ app . call env
72
69
73
70
env [ "REQUEST_METHOD" ] . should . equal "POST"
74
71
end
75
72
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
+
76
89
should "not modify REQUEST_METHOD for POST requests when the params are unparseable" do
77
90
env = Rack ::MockRequest . env_for ( "/" , :method => "POST" , :input => "(%bad-params%)" )
78
91
app . call env
You can’t perform that action at this time.
0 commit comments