Coldfusion 9 ListToArray bug
Quite some time ago CONTENS made the decision to have our products work on both Coldfusion and Railo thereby providing our customers with an option. This does tend to increase our testing times but we feel it is important to give our customers the option. As most, if not all, of you know Coldfusion 9 was recently released. The customers we have that are on Coldfusion 9 naturally want to take advantage of the new features and improvements that have been announced in CF.
During one such test cycle we discovered a bug in Coldfusion 9's implementation of ListToArray(), this bug does not exist in CF8. The bug appears when using a specific type of list delimiter "{}". The following is an example you can try out for yourself.
<cfset lMyList = "{key1:value1}{key2:value2}">
<cfset test = ListLen(lMyList, "{}")>
<cfset test2 = listToArray(lMyList, "{}")>
<cfdump var="#test#">
<cfdump var="#test2#">
Coldfusion 9 produces the following error message:
Illegal repetition {|}
The error occurred in D:\inetpub\wwwroot\cfstuff\listtoarray.cfm: line 5
3 : <cfset test = ListLen(lMyList, "{}")>
4 :
5 : <cfset test2 = listToArray(lMyList, "{}")>
6 :
7 :
Apparently this problem is only due to the curly braces, replacing the curly braces with "any" other character does not produce this problem. Why curly braces are being used I can't say but I believe this problem has something to do with the improvements in the implicit structures in CF9.
Happy Coding...

Subscribe
Subscribe via RSS
Follow me on Twitter
Or, Receive daily updates via email.
Tags
adobe air ajax apple cf community cfml coldfusion examples ext flash flex google javascript max2007 max2008 misc open source programming railo software technology ui
Recent Entries
No recent entries.
Blogroll
An Architect's View
CFSilence
Rey Bango
TalkingTree

Interesting. The stack shows CF is using some sort of regex to do the split. So I guess it makes sense that "{}" would cause an error.
Clearly a "feature", now we have to figure out, do we change our code or see if a fix comes out some how I think we can wait for a year before this gets looked at.
Writing code that suggests "{key1:value1}{key2:value2}" is a list delimited with the "{}" characters is unlikely to crop up in well-thought-out code, because it only works in the first place due to the forgivingness of CF's list functions. specifying "{}" as a list delimiter says that EITHER "{" or "}" is a delimiter, and there's no sense of those characters being braces that might be paired, nor is there a sense that the delimiter is "{}" as opposed to two separate delimiters, nor - given your data - is it sensible to treat the data as a list delmited like that. What a shambles.
There's definitely a bug in CF there, I agree. But if you are writing code like this and actually being caught out by this bug, you're bringing it upon yourself for writing bad, illogical code. Basically it's garbage-in, garbage out.
Still: raise an E/R and I'll vote for getting it fixed. http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbu...#
--
Adam
Not wanting to raise to the bait by your overly charged comment, but seriously without knowing where this is used and what specific reasons were chosen for the use of that delimiter I would be a little bit more careful with the garbage in garbage out comment. I can tell you that it was carefully chosen at the time the code was written for a specific use case. Whether it makes sense today is another story given the implicit structure and array declaration that now exists in CF.
Whatever a developer chooses to use as delimiter for a list is, in the end, completely irrelevant so long as he/she follows the rules stated in the documentation. That developer also has a certain expectation that upgrading won't break his code. That is the point of this article, not, in your opinion, the horrible choice of list delimiter.
And note I *did* actually agree with your point that it's a bug, and I've voted for your E/R.
Cheers.
--
Adam
There is another bug / different behavior between CF8 and CF9. Just to be aware Coldfusion9 ListToArray does not treat an element with a space in a list (e.g. "1, ,2" as an element in the array, but Coldfusion 8 does.
Have a look at this example:
<cfset array = listToArray("element1, ,element2")>
<cfdump var="#array#">
Coldfusion 9
array
1 element1
2 element2
Coldfusion 8:
array
1 element1
2
3 element2
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef...