Opened 14 years ago
Closed 14 years ago
#18240 closed defect (bug) (duplicate)
wp_localize_script() shouldn't convert character entities
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.2.1 |
Component: | I18N | Keywords: | |
Focuses: | Cc: |
Description
If you pass a string to wp_localize_script()
which contains special HTML characters such as "&" they'll get converted to their entities, resulting in JavaScript strings that contain entities when they shouldn't. Looks like the entity conversion in esc_js()
is the culprit.
Example:
wp_localize_script( 'myscript', 'something', array( 'message' => __( 'This & that', 'something' ) ) );
If you then do this:
alert( something.message );
the alert modal will show:
This & that
Change History (1)
Note: See
TracTickets for help on using
tickets.
I believe this was just fixed in [18464].
Marking as dup of #11520.
Please open a new ticket if there are other instances where esc_js() is causing problems like this.