[wp-trac] [WordPress Trac] #40899: '&' Is always escaped in the JavaScript template.
WordPress Trac
noreply at wordpress.org
Tue Sep 8 06:53:53 UTC 2020
#40899: '&' Is always escaped in the JavaScript template.
--------------------------+------------------------------
Reporter: tmatsuur | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.7.5
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by tmatsuur):
I'm sorry. I seem to have forgotten to attach the file.
The source code of the plugin is as follows.
{{{
<?php
/*
Plugin Name: Test JavaScript Template
Description: Test JavaScript Template.
Author: tmatsuur
Version: 0.0.1
*/
$test_javascript_template = new test_javascript_template();
class test_javascript_template {
public function __construct() {
add_action( 'wp_enqueue_scripts', array( $this, 'scripts'
) );
add_action( 'wp_footer', array( $this, 'footer' ), 9999 );
}
public function scripts() {
wp_enqueue_script( 'wp-util' );
}
public function footer() {
?>
<script type="text/template" id="tmpl-fields">
<div id="after_widget_search">
<p>&</p>
<p>Unscaped: {{{data.value}}}</p>
<p>Escaped: {{data.value}}</p>
</div>
</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>
<?php
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40899#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list