Articles

Ben & Ryan Show Guest Appearance - ColdFusion Custom UDFs

I get to share and explain some of my custom UDFs on a podcast with Ben & Ryan.

Image about Ben & Ryan Show Guest Appearance - ColdFusion Custom UDFs
April 23, 2025

I was invited to be a guest on the Ben & Ryan Show (hosted by xByte Solutions and Ben Nadel) to share some custom ColdFusion user-defined functions (UDFs).  UDFs are custom code blocks that you can create to perform specific tasks in your web applications, similar to reusable recipes. They help avoid repeating code, making development easier and more efficient. Back when CFML was solely tag-based, the CFFUNCTION tag was the built-in function (BIF) that enabled you to create a UDF. After CFScript emerged as an option in ColdFusion 9, UDFs can be written using a scripting style and the result looks a lot like javascript.

Disclaimer: If my eyes look a little odd during the first 4 minutes, it's because I was testing out the NVideo Broadcast app's "Eye Contact" feature.  I initially thought it would be a good idea since my camera is positioned between both of my 32" monitors and it never looks like I'm looking at the camera, but it tends to appear a little creepy at times.

I'm wearing a Shokz OPENCOMM2 bone conduction stero bluetooth headset during the show. (My version is the one right before the "2025 Upgrade".) My dotNET brother recommended these during a trip when the I expressed how frustrated I was with some new wireless earbuds that I had just purchased from Costco. When the headset is turned on, it automatically pairs with both my PC and my iPhone. These are so comfortable that I often foget that I'm wearing them. There's zero "headphone sweat" and I never have to adjust them in order to have a conversation with others around me in the real world.

Here's the UDFs that I shared during the show: 

  • hashid / ishashidValid - Protect against sequential traversal when using INT keys
  • createShadowHtml - Allows embedding of a full HTML document in a webpage; ie, email HTML preview
  • streamFindnocase - Searches the output buffer to determine if a string exists; Used for lazy dependency injection
  • generateEmailHashCode - Useful for identifying and blocking comment form abuse; SQL queries using INTs are faster
  • enableWKHTMLTOPDFForms - Modifies PDF bits so Adobe Reader treats PDF as "editable"
  • tempCache - Leverages cacheput/get to store temporary secrets; ie short-lived client variables-on-demand without having to enable client variables
  • jreEscape - Ensures strings can be safely used in regex patterns by preventing special characters from being interpreted as regex metacharacters
  • MaskCC - Strips all credit card variations from a string. Useful when sending/storing user-submitted data in order to remain compliant with VISA Payment Card Industry Data Security Standard (PCI DSS) requirements

NOTE: These UDFs should work on all CFML platforms with a minimum requirement of ACF2016+ due to some syntax used. No third-party executables are used, but I did use Java's replaceAll as I personally prefer it to the built-in reReplace & reReplaceNoCase functions.