Skip to content

Commit

Permalink
Arrays sent via multipart posts are converted to strings #1032 [dj@om…
Browse files Browse the repository at this point in the history
…elia.org]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1397 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jamis committed Jun 10, 2005
1 parent 6cff848 commit f6ec9e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*SVN*

* Arrays sent via multipart posts are converted to strings #1032 [dj@omelia.org]

* render(:layout => true) is a synonym for render(:layout => nil)

* Make sure the benchmarking render method always returns the output of the render.
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def CGIMethods.get_typed_value(value)
# Value as part of a multipart request
value.read
elsif value.class == Array
value
value.collect { | e | e.respond_to?(:read) ? e.read : e }
else
# Standard value (not a multipart request)
value.to_s
Expand Down
5 changes: 5 additions & 0 deletions actionpack/test/controller/cgi_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,16 @@ def test_parse_params_from_multipart_upload

input = {
"something" => [ StringIO.new("") ],
"array_of_stringios" => [[ StringIO.new("One"), StringIO.new("Two") ]],
"mixed_types_array" => [[ StringIO.new("Three"), "NotStringIO" ]],
"products[string]" => [ StringIO.new("Apple Computer") ],
"products[file]" => [ mock_file ]
}

expected_output = {
"something" => "",
"array_of_stringios" => ["One", "Two"],
"mixed_types_array" => [ "Three", "NotStringIO" ],
"products" => {
"string" => "Apple Computer",
"file" => mock_file
Expand Down Expand Up @@ -169,3 +173,4 @@ def test_parse_params_with_unmatched_brackets_and_array
assert_equal expected, CGIMethods.parse_request_parameters(input)
end
end

0 comments on commit f6ec9e3

Please sign in to comment.