Whatever message this page gives is out now! Go check it out!
GetSafeHTML() and AntiSamy policy files to do it<cfoutput>Hi <b>there</b></cfoutput> yourself. <script> or onerror= payload in that data executes exactly like it would in <cfoutput>#rawValue#</cfoutput>| Tag | Attribute / Field | Dynamic content | Sanitization |
|---|---|---|---|
<cfgrid> (via <cfgridcolumn>) | Grid cell data | Query column orbound data source | Required |
<cfgrid> | Group header | Same bound data as cell rendering | Required |
<cflayout> | Tab title | Usually static, but treat any dynamically-built title as untrusted | Required, if dynamic |
<cflayout> | Tab tabTip | Same | Required, if dynamic |
<cflayout> | Accordion title | Same | Required, if dynamic |
<cfwindow> | title | Docs explicitly allow HTML here | Required, if dynamic |
<cfmap> | markerWindowContent | Bound via markerBind — DATA, almost always dynamic in practice | Required |
<cftooltip> | Tooltip content | Response from sourceforTooltip (an AJAX call) — DATA | Required |
<cfrichtexteditor> | Editor content | Stored rich text (e.g., previously saved user content) — DATA | Required |
cfdiv / cfajaxproxy bind sinks | AJAX responseText rendered into the page | AJAX responseText rendered into the page | Required when the bound page contains untrusted data |
<cfoutput>
<cfset dirty = '<a href="https://example.com">link</a><script>alert(1)</script>'>
<cfset clean = GetSafeHTML(dirty)>
<p>Dirty: #EncodeForHTML(dirty)#</p>
<p>Clean: #EncodeForHTML(clean)#</p>
<p>Rendered: #clean#</p>
<p>Is safe? #IsSafeHTML(dirty)#</p>
<p>Is safe? #IsSafeHTML(clean)#</p>
</cfoutput>IsSafeHTML(value)GetSafeHTML(value [, policyFile, throwOnError])GetSafeHTML() / IsSafeHTML() , when run against an AntiSamy policy XML file, gets resolved in this order:policyFile argument. For example, GetSafeHTML(dirty, "path/to/mypolicy.xml")this.security.antisamypolicy = "path/to/mypolicy.xml"; in Application.cfc.<tag>/<attribute> rules for what your app actually needs. For example, antisamy-basic.xml has no <tag name="img"> rule at all, so <img> is stripped by default. If a field genuinely needs images (e.g., cfmap markerWindowContent, or cflayout tabTip, both confirmed used for <img>), add one, following the same pattern as the existing <tag name="a"> rule.