tracker issue : CF-3991872

select a category, or use search below
(searches all categories and all time range)
Title:

Form Fields with the same name are converted to arrays when Fusebox 5.5 is used.

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/AsDesigned

Reporter/Name(from Bugbase): Dan Wilson / Dan Wilson (Dan Wilson)

Created: 05/20/2015

Components: Language, Framework Support

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Normal / Most users will encounter

Locale/System: English / Win 2012 Server x64

Vote Count: 2

It appears the behavior of Form Fields with the same name has changed after I updated ColdFusion 11 to Update 5. The application had been working, but as of the update, we noticed form fields with the same name were coming through as Arrays. I added the this.sameformfieldsasarray = false in both the Application.cfc in the root of the project and also in the Application.cfc in the Fusebox framework, but I still get arrays when I access parameters in Fusebox.

Attached is a sample app, containing the Fusebox 5.5 files and a quick demonstration. After you run the code, you can open the Application.cfc in the Fusebox5 directory and verify the this.sameformfieldsasarray parameter is set. A few lines down, there is the following code:
	<cfset structAppend(attributes,URL,true) />
	<cfset structAppend(attributes,form,true) />

Dumping Form or URL in this Application.cfc results in Arrays for any formfields with the same name. If the form fields are text boxes, the array is sized for the number of elements, regardless of whether there is any text in the text box. Checkboxes are different and only populated checkboxes are added to the array.


Problem Description:
Form fields with the same name are combined into an array when using an Application.cfm file on Windows 2012 x64 install of ColdFusion 11 update 5.

The setting should be off by default.

Steps to Reproduce:
Unzip the attachment into your webroot.
Call it like this: http://localhost/testcase/index.cfm?fuseaction=util.formfields
Add values to the form text fields and also check some of the checkboxes. 
Push the submit button. Both the form scope, and the specific values will be dumped to the screen. Note, the values coming through Fusebox will be arrays.


The string <cfset this.sameformfieldsasarray = "false" /> has been added to the Application.cfc in the root of the application, as well as the Application.cfc in the Fusebox framework.



Actual Result:
The form struct contains an array called formField

Expected Result:
The form struct should contain a list called formField

Any Workarounds:
Can loop through the form scope on every request and convert arrays to lists

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3991872

External Customer Info:
External Company:  
External Customer Name: Dan
External Customer Email:  
External Test Config: My Hardware and Environment details:

Server Product	ColdFusion

Version	11,0,05,293506

Tomcat Version	7.0.54.0

Edition	Enterprise  

Operating System	Windows Server 2012  

OS Version	6.2  

Update Level	C:/ColdFusion11/cfusion/lib/updates/chf11000005.jar  

Adobe Driver Version	5.1.3 (Build 000094)  

JVM Details

Java Version	1.7.0_51  

Java Vendor	Oracle Corporation  

Java Vendor URL	http://java.oracle.com/

Java Home	C:\ColdFusion11\jre  

Java File Encoding	Cp1252  

Java Default Locale	en_US

Attachments:

  1. May 21, 2015 00:00:00: 1_TestCase.zip
  2. September 02, 2015 00:00:00: 2_0-all_checkboxes.png
  3. September 02, 2015 00:00:00: 3_1-one_checkbox.png
  4. September 02, 2015 00:00:00: 4_2-no-checkbox.png

Comments:

We followed the steps you have mentioned. FormField Values come as list in the form struct . Here is the dump of struct that I get when I run the code: struct FIELDNAMES NODUPE,NOARRAY,SUBMIT NOARRAY 1 NODUPE 1,1,122 SUBMIT submit Can you help us with some more information which would help us to reproduce the issue? Thanks!
Comment by Suchika S.
7346 | June 05, 2015 02:48:06 AM GMT
I can confirm the issue with an application after moving from a fusebox application.cfm configuration to a application.cfc. The TestCase.zip actually shows the issue in my case. I am using cf11 u6. The page displays: Text Fields array 1 1 2 1 3 1 Checkboxes array 1 1 2 1 3 1 Form Scope struct FIELDNAMES NODUPE,NOARRAY,SUBMIT NOARRAY 1,1,1 NODUPE 1,1,1 SUBMIT submit The issue lies in the values returned by fusebox: they are array where they were expected to be lists. The structure posted in the comment by Suchika Singh is actually the posted form. The 2 arrays above are what we receive from fusebox.
Comment by External U.
7347 | September 01, 2015 01:38:42 AM GMT
This is an unsuspected bug that impacts the migration of old applications from coldfusion <10 to 10 or 11, especially in a company environment.
Vote by External U.
7353 | September 01, 2015 05:38:52 PM GMT
I've added screenshots: * 0-all_checkboxes.png is the array returned when 2 or more checkboxes with the same name are selected. * 1-one_checkbox.png shows that with 1 or less checkbox selected, the result becomes a string!! This should at least be consistent and return and array. * 2-no-checkbox.png shows the result when not selecting any checkbox. The result is an empty string.
Comment by External U.
7348 | September 01, 2015 08:04:01 PM GMT
Hi Suchika, The repro is simple. On 5/21/2015, Krishna verified my repro here: http://prerelease.adobe.com/r/?7dc29612438c4f35b60a41dd1a7daca8 Repro: Application.cfc: component { THIS.name = "ticket_CF-3991872"; THIS.sameFormFieldsAsArray = false; broke={}; structAppend(broke, FORM, true);//THIS.sameFormFieldsAsArray is still true here, so duplicate form fields are still arrays structAppend(broke, URL, true); boolean function onRequestStart() { fixed={}; structAppend(fixed, FORM, true););//THIS.sameFormFieldsAsArray is now false, so duplicate form fields are now strings structAppend(fixed, URL, true); return true; } void function onRequest() { include "index.cfm"; } } index.cfm: <cfdump var="#broke#" format="text"> <cfdump var="#fixed#" format="text"> <form method="post"> <input name="foo" value="a"> <input name="foo" value="b"> <input name="foo" value="c"> <input type="checkbox" name="bar" checked="checked"> <input type="checkbox" name="bar"> <input type="checkbox" name="bar" checked="checked"> <input type="submit" name="submit"> </form> Just compare the dumps. Per-app settings aren’t taking effect soon enough. Since Krishna already verified this, could this ticket please be marked Verified? Thanks!, -Aaron
Comment by External U.
7349 | September 02, 2015 12:09:31 AM GMT
+1 - THIS.sameFormFieldsAsArray defaults to true w/in Application.cfc's pseudo-constructor (bug). After Application.cfc's initialization code has ran, THIS.sameFormFieldsAsArray defaults to false. Since Fusebox merges the FORM and URL scopes w/in Application.cfc's pseudo-constructor, the issue in this ticket arises.
Vote by External U.
7354 | September 02, 2015 02:04:06 AM GMT
Temporary workaround: I got the expected output by moving the following from fusebox5\Application.cfc's pseudo-constructor into its onRequestStart(): <cfset structAppend(attributes,URL,true) /> <cfset structAppend(attributes,form,true) /> Of course this ticket should still be fixed. Thanks!, -Aaron
Comment by External U.
7350 | September 02, 2015 02:08:37 AM GMT
Sending the bug to ToFix. Changing dev to KP as he knows about the issue.
Comment by Suchika S.
7351 | September 21, 2015 02:24:51 AM GMT
The setting sameformfieldsasarray is designed to work in the subsequent calls post the psuedo-constructor. And at the same time, as per the HTTP RFC spec http://www.ietf.org/rfc/rfc2388.txt, we do have to keep the form fields as array by default internally(This is the change post ColdFusion 9). We tried to fix this but it breaks other functionalities. Given that this is an edge case and work around is there, we are cautious not to fix this. If you you have concerns, please let us know.
Comment by Krishna R.
7352 | September 21, 2016 12:44:34 AM GMT