Bug with IsSimpleValue

IsSimpleValue is a function that lets you check if a value is a simple string, number, boolean, or datetime value. If the function returns true, you can always place it directly in cfoutput. However, yesterday I noticed something odd.

If you pass in a string that contains XML, the function will return false. It is almost as if CF thinks, “Oh, this is XML, it must be an XML object.” However, the value is plainly a string. In fact, if you run uCase, or trim, or any other string function on it, and pass the result to isSimpleValue, it will return true.

Here is a simple block of code that demonstrates the bug:

<FONT COLOR=MAROON><cfhttp url=<FONT COLOR=BLUE>"http://www.macromedia.com/devnet/resources/macromedia_resources.rdf"</FONT>></FONT>
<FONT COLOR=MAROON><cfif isSimpleValue(cfhttp.fileContent)></FONT>
   Yes, it is a simple value.
<FONT COLOR=MAROON><cfelse></FONT>
   No, it is not.
<FONT COLOR=MAROON></cfif></FONT>
<FONT COLOR=NAVY><p></FONT>
<FONT COLOR=MAROON><cfif isSimpleValue(lCase(cfhttp.fileContent))></FONT>
   Yes, it is a simple value.
<FONT COLOR=MAROON><cfelse></FONT>
   No, it is not.
<FONT COLOR=MAROON></cfif></FONT>

Note - this bug affects my rss.cfc that I released last week. Later in the day I’ll release an update.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments