Changes between Initial Version and Version 1 of Ticket #51159
- Timestamp:
- 08/27/2020 06:59:19 PM (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #51159 – Description
initial v1 150 150 PHP’s `json_encode()` has an `$options` parameter, which can be used to always Unicode-escape these HTML special characters: 151 151 152 {{{ 152 153 ALMOST (PHP 5.3+): 153 154 <script> 154 155 var foo = <?php echo wp_json_encode( $foo, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); ?>; 155 156 </script> 157 }}} 156 158 157 159 These constants are only available as of PHP 5.3. 158 160 159 Also, just replacing those characters isn’t good enough. We also need to Unicode-escape ``` and `$` because of their special meanings in JavaScript template literals. 160 161 GOOD (PHP 5.3+): 161 Also, just replacing those characters isn’t good enough. We also need to Unicode-escape ``` and `$` because of their special meanings in JavaScript template literals. 162 162 163 163 {{{ 164 GOOD (PHP 5.3+): 164 165 <script> 165 166 var message = `hello, ${<?php echo str_replace(
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)