encodeFor
Encodes a given string for safe output in the specified context. The encoding is meant to mitigate Cross Site Scripting (XSS) attacks.
encodeFor(type, value) → returns string
This function requires Adobe ColdFusion 2016 and up. Not supported on Lucee, etc.
Argument Reference
type string Required
The context of the encoding to perform.
Values:
cssdnhtmlhtmlattributejavascriptldapurlxmlxmlattributexpath
value string Required
The value to encode.
Examples Sample code invoking the encodeFor function
Pass in a tag and HTML encode the result.
encodeFor("html","<br>") Expected Result: <br>
© 2012–present Foundeo, Inc. and the CFDocs contributors.
Licensed under the MIT License.
ColdFusion is a trademark of Adobe Systems Incorporated.
https://cfdocs.org/encodefor