Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#18240 closed defect (bug) (duplicate)

wp_localize_script() shouldn't convert character entities

Reported by: johnbillion's profile johnbillion Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: I18N Keywords:
Focuses: Cc:


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.


		'message'  => __( 'This & that', 'something' )

If you then do this:

alert( something.message );

the alert modal will show:

This & that

Change History (1)

#1 @scribu
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

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.

Note: See TracTickets for help on using tickets.