Skip to content

Instantly share code, notes, and snippets.

@coldfumonkeh
Created October 22, 2012 10:15
Show Gist options
  • Save coldfumonkeh/3930771 to your computer and use it in GitHub Desktop.
Save coldfumonkeh/3930771 to your computer and use it in GitHub Desktop.
Use the ESAPI canonicalize security function in ColdFusion 8.01 and 9
<cfset strText = 'Hello, world. This is the &lt;strong&gt;greatest&lt;/strong&gt; example in the world.' />
<!--- Instantiate the ESAPI object. --->
<cfset objESAPI = createObject("java","org.owasp.esapi.ESAPI") />
<!--- Assign the Encoder class to a new variable. --->
<cfset objEncoder = objESAPI.encoder() />
<!--- Canonicalize the provided string. --->
<cfset strClean = objEncoder.canonicalize(strText, false, false) />
<!---
In this example we created a separate object for the Encoder class.
You could simply call the canonicalize function this way, too:
<cfset strClean = objESAPI.encoder().canonicalize('whatever your input string is') />
--->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment