Spec-Zone.ru › ColdFusion

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.
  • CF2016+
  • See Also: encodeForHTML canonicalize esapiEncode

    Argument Reference

    type string
    Required

    The context of the encoding to perform.
    Values:
    • css
    • dn
    • html
    • htmlattribute
    • javascript
    • ldap
    • url
    • xml
    • xmlattribute
    • xpath

    value string
    Required

    The value to encode.

    Examples
    Sample code invoking the encodeFor function

    Simple encodeFor Example

    Pass in a tag and HTML encode the result.

    encodeFor("html","<br>")

    Expected Result: &lt;br&gt;

    © 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

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API