[wp-trac] [WordPress Trac] #63851: Audit wp_json_encode usage with script tags

WordPress Trac noreply at wordpress.org
Wed Aug 27 10:33:14 UTC 2025


#63851: Audit wp_json_encode usage with script tags
--------------------------------------+-------------------------
 Reporter:  jonsurrell                |       Owner:  jonsurrell
     Type:  task (blessed)            |      Status:  closed
 Priority:  normal                    |   Milestone:  6.9
Component:  General                   |     Version:
 Severity:  normal                    |  Resolution:  fixed
 Keywords:  good-first-bug has-patch  |     Focuses:  javascript
--------------------------------------+-------------------------
Changes (by jonsurrell):

 * owner:  (none) => jonsurrell
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"60681" 60681]:
 {{{
 #!CommitTicketReference repository="" revision="60681"
 Scripts: Use appropriate JSON encoding flags for script tags.

 `wp_json_encode()` with default arguments is insufficient to safely escape
 JSON for script tags. Use `JSON_HEX_TAG | JSON_UNESCAPED_SLASHES` flags.

 Developed in https://github.com/WordPress/wordpress-develop/pull/9557.

 Props devasheeshkaul, jonsurrell, siliconforks.
 Fixes #63851.
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63851#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list