Encodes the inputString for safe output in the attribute value of an HTML attribute, such as table width or image height. The encoding is meant to mitigate Cross Site Scripting (XSS) attacks.

encodeForHTMLAttribute(inputString [, canonicalize]) → returns string

encodeForHTMLAttribute Argument Reference

inputString string

A string to encode

canonicalize boolean

When true runs the canonicalize function against the input before encoding. This argument is not supported on Lucee.

Links more information about encodeForHTMLAttribute

Examples sample code invoking the encodeForHTMLAttribute function

Shows how and where encodeForHTMLAttribute would be used.

<cfoutput><div title="#encodeForHTMLAttribute("<test>")#"></cfoutput>

Expected Result: <div title="&lt;test&gt;">

Fork me on GitHub