Skip to content

Security: ensure second arg of wp_localize_script() is properly escaped #1253

Open
@JDGrimes

Description

@JDGrimes

The second arg of the wp_localize_script() function, $object_name, is directly interpolated into the JS without any escaping. Per the docs:

 * @param string $object_name Name for the JavaScript object. Passed directly, so it should be qualified JS variable.
 *                            Example: '/[a-zA-Z0-9_]+/'.

Believe it or not, some plugins use dynamic object names, even incorporating untrusted data. I think it makes sense add a sniff that requires the value to be properly escaped.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions