Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes #2439. ActionController::Integration::Session no longer mangles…

… multiparameter attribute params when processing multipart requests.

Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information...
commit d63fab344f5321ea71198ac349fea1ee15773f7d 1 parent c5c022c
Steven Luscher steveluscher authored NZKoz committed
2  actionpack/lib/action_controller/integration.rb
View
@@ -409,7 +409,7 @@ def requestify(parameters, prefix=nil)
def multipart_requestify(params, first=true)
returning Hash.new do |p|
params.each do |key, value|
- k = first ? CGI.escape(key.to_s) : "[#{CGI.escape(key.to_s)}]"
+ k = first ? key.to_s : "[#{key.to_s}]"
if Hash === value
multipart_requestify(value, false).each do |subkey, subvalue|
p[k + subkey] = subvalue
28 actionpack/test/controller/integration_test.rb
View
@@ -240,6 +240,14 @@ def get_with_params
render :text => "foo: #{params[:foo]}", :status => 200
end
+ def post_with_multiparameter_params
+ render :text => "foo(1i): #{params[:"foo(1i)"]}, foo(2i): #{params[:"foo(2i)"]}", :status => 200
+ end
+
+ def multipart_post_with_multiparameter_params
+ render :text => "foo(1i): #{params[:"foo(1i)"]}, foo(2i): #{params[:"foo(2i)"]}, filesize: #{params[:file].size}", :status => 200
+ end
+
def post
render :text => "Created", :status => 201
end
@@ -255,6 +263,8 @@ def redirect
end
end
+ FILES_DIR = File.dirname(__FILE__) + '/../fixtures/multipart'
+
def test_get
with_test_route_set do
get '/get'
@@ -360,6 +370,24 @@ def test_get_with_parameters
end
end
+ def test_post_with_multiparameter_attribute_parameters
+ with_test_route_set do
+ post '/post_with_multiparameter_params', :"foo(1i)" => "bar", :"foo(2i)" => "baz"
+
+ assert_equal 200, status
+ assert_equal "foo(1i): bar, foo(2i): baz", response.body
+ end
+ end
+
+ def test_multipart_post_with_multiparameter_attribute_parameters
+ with_test_route_set do
+ post '/multipart_post_with_multiparameter_params', :"foo(1i)" => "bar", :"foo(2i)" => "baz", :file => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg")
+
+ assert_equal 200, status
+ assert_equal "foo(1i): bar, foo(2i): baz, filesize: 159528", response.body
+ end
+ end
+
def test_head
with_test_route_set do
head '/get'
Please sign in to comment.
Something went wrong with that request. Please try again.