[Skratchdot.]

Archive for the ‘ColdFusion’ Category:

This weekend I read an interesting blog post called “JSON: The JavaScript subset that isn’t” and decided to test ColdFusion’s SerializeJSON() function to see if the “bug” existed there. It does. To reproduce, you can create a .cfm page that contains the following HTML/CF code:

1
2
3
<script type="text/javascript">
    var test = #SerializeJSON("test" & chr(8232))#;
</script>

To “fix” the bug, you can replace SerializeJSON() with SafeSerializeJSON() like this:

Tagged with:

Recently I was asked how to programmatically verify ColdFusion DataSources. I came up with a few methods of doing so. Each have their pros and cons.

 

Method #1 : Try/Catch using cfquery

 
PROS:
  • Can test for “datasource” specific behavior by using a custom cfquery. If you do this, the query may not work for other datasources, thereby not actually testing the validity of the datasource.
 
CONS:
  • Uses try/catch.
  • Does not work with all datasources. I don’t know of a cfquery that will work for all datasources / DBs / etc
 
NOTES:
This is my least favorite, because I couldn’t come up with a cfquery to test *all* datasources. It will work for some datasources, but not all.
 
SOURCE:
Tagged with: