When the request is a multipart POST, merb uses different logic for parsing the form fields, but what ends up happening is that they aren't parsed consistently with regular POST or GET requests.
Examples:
GET and regular POST request:
foo=bar&test[abc]=xyz&test[123]=baz =>
{"foo"=>"bar", "test"=>{"abc"=>"xyz", "123"=>"baz"}}
Multipart POST:
(these are examples from my test program)
commit=upload
media_item[description]=test
media_item[file_type] = Image
media_item[uploaded_data] = a file name
{"commit"=>"Upload", "action"=>"upload", "media_item[uploaded_data]"=>{"name"=>"media_item[uploaded_data]", "type"=>"image/jpeg", "tempfile"=>#<File:/tmp/Merb25539-0>, "filename"=>"Photo 3.jpg"}, "controller"=>"upload", "media_item[file_type]"=>"Image", "media_item[description]"=>"test"}
As you can see, the media_item parameters are not grouped like they should be.
I think it comes down to this logic in the Merb::Controller class:
if name =~ /(.*)?\[\]/
(querystring[$1] ||= []) << attrs
else
querystring[name]=attrs if name
end
First of all, that regexp is wrong, so the else branch is always executed.
Second, I don't think this will handle the case where there are multiple nestings: foo[bar][baz].
Sorry for lack of a test case, I wanted to get this debugged and submitted before I leave work today.