Make WordPress Core

Opened 3 years ago

#40899 new defect (bug)

'&' Is always escaped in the JavaScript template.

Reported by: tmatsuur Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7.5
Component: General Keywords:
Focuses: Cc:


When I tried the JavaScript template, '&' was always escaped.


<script type="text/template" id="tmpl-fields">
<p>Unscaped: {{{data.value}}}</p>
<p>Escaped: {{data.value}}</p>
<script type="text/javascript">
( function($) {
	$(document).ready( function () {
		var template = wp.template( 'fields' );
		$( '.widget_search' ).after( template( { value: "W<i>o</i>&r'l\"d" } ) );
	} );
} )( jQuery );


<p>Unscaped: W<i>o</i>&amp;r'l"d</p>
<p>Escaped: W&lt;i&gt;o&lt;/i&gt;&amp;r'l"d</p>

While checking the interpolation of the variable, '&' was always converted to '& amp;'.
Is this a specification or a bug?

Change History (0)

Note: See TracTickets for help on using tickets.