[wp-trac] [WordPress Trac] #40899: '&' Is always escaped in the JavaScript template.
WordPress Trac
noreply at wordpress.org
Thu Jun 1 08:41:14 UTC 2017
#40899: '&' Is always escaped in the JavaScript template.
--------------------------+-----------------------------
Reporter: tmatsuur | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.7.5
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
When I tried the JavaScript template, '&' was always escaped.
Source:
{{{
<script type="text/template" id="tmpl-fields">
<p>&</p>
<p>Unscaped: {{{data.value}}}</p>
<p>Escaped: {{data.value}}</p>
</script>
<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 );
</script>
}}}
Rendering:
{{{
<p>&</p>
<p>Unscaped: W<i>o</i>&r'l"d</p>
<p>Escaped: W<i>o</i>&r'l"d</p>
}}}
While checking the interpolation of the variable, '&' was always converted
to '& amp;'.
Is this a specification or a bug?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40899>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list