Changeset 60681
- Timestamp:
- 08/27/2025 10:32:57 AM (8 weeks ago)
- Location:
- trunk
- Files:
-
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/async-upload.php
r60637 r60681 146 146 ); 147 147 148 echo '<script>_.delay(function() {wp.a11y.speak(' . wp_json_encode( $speak_message ) . ");}, 1500);jQuery( 'button#{$button_unique_id}' ).on( 'click', function() {jQuery(this).parents('div.media-item').slideUp(200, function(){jQuery(this).remove();wp.a11y.speak( wp.i18n.__( 'Error dismissed.' ) );jQuery( '#plupload-browse-button' ).trigger( 'focus' );})});</script>\n";148 echo '<script>_.delay(function() {wp.a11y.speak(' . wp_json_encode( $speak_message, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ");}, 1500);jQuery( 'button#{$button_unique_id}' ).on( 'click', function() {jQuery(this).parents('div.media-item').slideUp(200, function(){jQuery(this).remove();wp.a11y.speak( wp.i18n.__( 'Error dismissed.' ) );jQuery( '#plupload-browse-button' ).trigger( 'focus' );})});</script>\n"; 149 149 exit; 150 150 } -
trunk/src/wp-admin/customize.php
r59945 r60681 63 63 <?php wp_print_scripts( array( 'wp-util' ) ); ?> 64 64 <script> 65 wp.ajax.post( 'customize_save', <?php echo wp_json_encode( $request_args ); ?> );65 wp.ajax.post( 'customize_save', <?php echo wp_json_encode( $request_args, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> ); 66 66 </script> 67 67 <?php … … 159 159 160 160 <script type="text/javascript"> 161 var ajaxurl = <?php echo wp_json_encode( admin_url( 'admin-ajax.php', 'relative' ) ); ?>,161 var ajaxurl = <?php echo wp_json_encode( admin_url( 'admin-ajax.php', 'relative' ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?>, 162 162 pagenow = 'customize'; 163 163 </script> -
trunk/src/wp-admin/edit-form-blocks.php
r59958 r60681 116 116 wp_add_inline_script( 117 117 'wp-blocks', 118 sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( $post ) ) ),118 sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( $post ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ), 119 119 'after' 120 120 ); … … 145 145 wp_add_inline_script( 146 146 'wp-blocks', 147 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'147 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ');' 148 148 ); 149 149 … … 159 159 ); 160 160 } 161 $script = sprintf( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources ) );161 $script = sprintf( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ); 162 162 wp_add_inline_script( 163 163 'wp-blocks', … … 179 179 wp_add_inline_script( 180 180 'wp-editor', 181 sprintf( 'var _wpMetaBoxUrl = %s;', wp_json_encode( $meta_box_url ) ),181 sprintf( 'var _wpMetaBoxUrl = %s;', wp_json_encode( $meta_box_url, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ), 182 182 'before' 183 183 ); … … 365 365 $post->post_type, 366 366 $post->ID, 367 wp_json_encode( $editor_settings ),368 wp_json_encode( $initial_edits )367 wp_json_encode( $editor_settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 368 wp_json_encode( $initial_edits, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 369 369 ); 370 370 wp_add_inline_script( 'wp-edit-post', $script ); -
trunk/src/wp-admin/includes/class-wp-internal-pointers.php
r55916 r60681 121 121 <script type="text/javascript"> 122 122 (function($){ 123 var options = <?php echo wp_json_encode( $args ); ?>, setup;123 var options = <?php echo wp_json_encode( $args, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?>, setup; 124 124 125 125 if ( ! options ) -
trunk/src/wp-admin/includes/class-wp-list-table.php
r60613 r60681 1872 1872 ); 1873 1873 1874 printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) );1874 printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ); 1875 1875 } 1876 1876 } -
trunk/src/wp-admin/includes/class-wp-privacy-policy-content.php
r59733 r60681 349 349 'wp.data.dispatch( "core/notices" ).createWarningNotice( "%s", { actions: [ %s ], isDismissible: false } )', 350 350 $message, 351 wp_json_encode( $action )351 wp_json_encode( $action, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 352 352 ), 353 353 'after' -
trunk/src/wp-admin/includes/class-wp-themes-list-table.php
r59675 r60681 358 358 } 359 359 360 printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode( $args ) );360 printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode( $args, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ); 361 361 parent::_js_vars(); 362 362 } -
trunk/src/wp-admin/includes/media.php
r60449 r60681 275 275 <script type="text/javascript"> 276 276 var win = window.dialogArguments || opener || parent || top; 277 win.send_to_editor( <?php echo wp_json_encode( $html ); ?> );277 win.send_to_editor( <?php echo wp_json_encode( $html, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> ); 278 278 </script> 279 279 <?php … … 2237 2237 ?> 2238 2238 var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>, 2239 wpUploaderInit = <?php echo wp_json_encode( $plupload_init ); ?>;2239 wpUploaderInit = <?php echo wp_json_encode( $plupload_init, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?>; 2240 2240 </script> 2241 2241 -
trunk/src/wp-admin/includes/misc.php
r60658 r60681 1086 1086 } 1087 1087 1088 echo '<script type="text/javascript">var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ) ) . ";</script>\n";1088 echo '<script type="text/javascript">var _wpColorScheme = ' . wp_json_encode( array( 'icons' => $icon_colors ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ";</script>\n"; 1089 1089 } 1090 1090 -
trunk/src/wp-admin/includes/options.php
r57713 r60681 38 38 var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(), 39 39 $siteIconPreview = $('#site-icon-preview-site-title'), 40 homeURL = ( <?php echo wp_json_encode( get_home_url() ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' );40 homeURL = ( <?php echo wp_json_encode( get_home_url(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' ); 41 41 42 42 $( '#blogname' ).on( 'input', function() { -
trunk/src/wp-admin/includes/post.php
r60275 r60681 2443 2443 */ 2444 2444 $script = 'window._wpLoadBlockEditor.then( function() { 2445 wp.data.dispatch( \'core/edit-post\' ).setAvailableMetaBoxesPerLocation( ' . wp_json_encode( $meta_boxes_per_location ) . ' );2445 wp.data.dispatch( \'core/edit-post\' ).setAvailableMetaBoxesPerLocation( ' . wp_json_encode( $meta_boxes_per_location, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ' ); 2446 2446 } );'; 2447 2447 -
trunk/src/wp-admin/includes/template.php
r60658 r60681 2480 2480 ?> 2481 2481 <script type="text/javascript"> 2482 var compressionNonce = <?php echo wp_json_encode( wp_create_nonce( 'update_can_compress_scripts' ) ); ?>;2482 var compressionNonce = <?php echo wp_json_encode( wp_create_nonce( 'update_can_compress_scripts' ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?>; 2483 2483 var testCompression = { 2484 2484 get : function(test) { -
trunk/src/wp-admin/plugin-editor.php
r60479 r60681 161 161 ); 162 162 wp_enqueue_script( 'wp-theme-plugin-editor' ); 163 wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'jQuery( function( $ ) { wp.themePluginEditor.init( $( "#template" ), %s ); } )', wp_json_encode( $settings ) ) );163 wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'jQuery( function( $ ) { wp.themePluginEditor.init( $( "#template" ), %s ); } )', wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) ); 164 164 wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'wp.themePluginEditor.themeOrPlugin = "plugin";' ) ); 165 165 -
trunk/src/wp-admin/site-editor.php
r60134 r60681 258 258 wp.editSite.initializeEditor( "site-editor", %s ); 259 259 } );', 260 wp_json_encode( $editor_settings )260 wp_json_encode( $editor_settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 261 261 ) 262 262 ); … … 265 265 wp_add_inline_script( 266 266 'wp-blocks', 267 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'267 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ');' 268 268 ); 269 269 … … 279 279 ); 280 280 } 281 $script = sprintf( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources ) );281 $script = sprintf( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ); 282 282 wp_add_inline_script( 283 283 'wp-blocks', … … 288 288 wp_add_inline_script( 289 289 'wp-blocks', 290 sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( isset( $editor_settings['blockCategories'] ) ? $editor_settings['blockCategories'] : array() ) ),290 sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( isset( $editor_settings['blockCategories'] ) ? $editor_settings['blockCategories'] : array(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ), 291 291 'after' 292 292 ); -
trunk/src/wp-admin/theme-editor.php
r59884 r60681 147 147 ); 148 148 wp_enqueue_script( 'wp-theme-plugin-editor' ); 149 wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'jQuery( function( $ ) { wp.themePluginEditor.init( $( "#template" ), %s ); } )', wp_json_encode( $settings ) ) );149 wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'jQuery( function( $ ) { wp.themePluginEditor.init( $( "#template" ), %s ); } )', wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) ); 150 150 wp_add_inline_script( 'wp-theme-plugin-editor', 'wp.themePluginEditor.themeOrPlugin = "theme";' ); 151 151 -
trunk/src/wp-admin/widgets-form-blocks.php
r59238 r60681 42 42 wp.editWidgets.initialize( "widgets-editor", %s ); 43 43 } );', 44 wp_json_encode( $editor_settings )44 wp_json_encode( $editor_settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 45 45 ) 46 46 ); … … 49 49 wp_add_inline_script( 50 50 'wp-blocks', 51 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'51 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ');' 52 52 ); 53 53 … … 63 63 ); 64 64 } 65 $script = sprintf( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources ) );65 $script = sprintf( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ); 66 66 wp_add_inline_script( 67 67 'wp-blocks', … … 72 72 wp_add_inline_script( 73 73 'wp-blocks', 74 sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( $block_editor_context ) ) ),74 sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( $block_editor_context ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ), 75 75 'after' 76 76 ); -
trunk/src/wp-content/themes/twentytwenty/functions.php
r60536 r60681 685 685 sprintf( 686 686 'wp.customize.selectiveRefresh.partialConstructor[ %1$s ].prototype.attrs = %2$s;', 687 wp_json_encode( 'cover_opacity' ),688 wp_json_encode( twentytwenty_customize_opacity_range() )687 wp_json_encode( 'cover_opacity', JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 688 wp_json_encode( twentytwenty_customize_opacity_range(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 689 689 ) 690 690 ); -
trunk/src/wp-includes/class-wp-customize-manager.php
r60522 r60681 477 477 var preview = new api.Messenger( settings.messengerArgs ); 478 478 preview.send( 'iframe-loading-error', settings.error ); 479 } )( wp.customize, <?php echo wp_json_encode( $settings ); ?> );479 } )( wp.customize, <?php echo wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> ); 480 480 </script> 481 481 <?php … … 2206 2206 ?> 2207 2207 <script> 2208 var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>;2208 var _wpCustomizeSettings = <?php echo wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?>; 2209 2209 _wpCustomizeSettings.values = {}; 2210 2210 (function( v ) { … … 2219 2219 printf( 2220 2220 "v[%s] = %s;\n", 2221 wp_json_encode( $id ),2222 wp_json_encode( $setting->js_value() )2221 wp_json_encode( $id, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 2222 wp_json_encode( $setting->js_value(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 2223 2223 ); 2224 2224 } … … 4989 4989 ?> 4990 4990 <script> 4991 var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>;4991 var _wpCustomizeSettings = <?php echo wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?>; 4992 4992 _wpCustomizeSettings.initialClientTimestamp = _.now(); 4993 4993 _wpCustomizeSettings.controls = {}; … … 5001 5001 printf( 5002 5002 "s[%s] = %s;\n", 5003 wp_json_encode( $setting->id ),5004 wp_json_encode( $setting->json() )5003 wp_json_encode( $setting->id, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 5004 wp_json_encode( $setting->json(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 5005 5005 ); 5006 5006 } … … 5014 5014 printf( 5015 5015 "c[%s] = %s;\n", 5016 wp_json_encode( $control->id ),5017 wp_json_encode( $control->json() )5016 wp_json_encode( $control->id, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 5017 wp_json_encode( $control->json(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 5018 5018 ); 5019 5019 } -
trunk/src/wp-includes/class-wp-customize-nav-menus.php
r59948 r60681 546 546 ); 547 547 548 $data = sprintf( 'var _wpCustomizeNavMenusSettings = %s;', wp_json_encode( $settings ) );548 $data = sprintf( 'var _wpCustomizeNavMenusSettings = %s;', wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ); 549 549 wp_scripts()->add_data( 'customize-nav-menus', 'data', $data ); 550 550 … … 1549 1549 'navMenuInstanceArgs' => $this->preview_nav_menu_instance_args, 1550 1550 ); 1551 wp_print_inline_script_tag( sprintf( 'var _wpCustomizePreviewNavMenusExports = %s;', wp_json_encode( $exports ) ) );1551 wp_print_inline_script_tag( sprintf( 'var _wpCustomizePreviewNavMenusExports = %s;', wp_json_encode( $exports, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) ); 1552 1552 } 1553 1553 -
trunk/src/wp-includes/class-wp-customize-widgets.php
r60290 r60681 833 833 'customize-widgets', 834 834 'data', 835 sprintf( 'var _wpCustomizeWidgetsSettings = %s;', wp_json_encode( $settings ) )835 sprintf( 'var _wpCustomizeWidgetsSettings = %s;', wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) 836 836 ); 837 837 … … 860 860 wp.customizeWidgets.initialize( "widgets-customizer", %s ); 861 861 } );', 862 wp_json_encode( $editor_settings )862 wp_json_encode( $editor_settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 863 863 ) 864 864 ); … … 867 867 wp_add_inline_script( 868 868 'wp-blocks', 869 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'869 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings(), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ');' 870 870 ); 871 871 … … 881 881 ); 882 882 } 883 $script = sprintf( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources ) );883 $script = sprintf( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ); 884 884 wp_add_inline_script( 885 885 'wp-blocks', … … 890 890 wp_add_inline_script( 891 891 'wp-blocks', 892 sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( $block_editor_context ) ) ),892 sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( $block_editor_context ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ), 893 893 'after' 894 894 ); … … 1335 1335 } 1336 1336 wp_print_inline_script_tag( 1337 sprintf( 'var _wpWidgetCustomizerPreviewSettings = %s;', wp_json_encode( $settings ) )1337 sprintf( 'var _wpWidgetCustomizerPreviewSettings = %s;', wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) 1338 1338 ); 1339 1339 } -
trunk/src/wp-includes/class-wp-script-modules.php
r59505 r60681 249 249 if ( ! empty( $import_map['imports'] ) ) { 250 250 wp_print_inline_script_tag( 251 wp_json_encode( $import_map, JSON_HEX_TAG | JSON_ HEX_AMP),251 wp_json_encode( $import_map, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 252 252 array( 253 253 'type' => 'importmap', -
trunk/src/wp-includes/class-wp-scripts.php
r58878 r60681 597 597 } 598 598 599 $script = "var $object_name = " . wp_json_encode( $l10n ) . ';';599 $script = "var $object_name = " . wp_json_encode( $l10n, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ';'; 600 600 601 601 if ( ! empty( $after ) ) { -
trunk/src/wp-includes/customize/class-wp-customize-selective-refresh.php
r56687 r60681 194 194 195 195 // Export data to JS. 196 wp_print_inline_script_tag( sprintf( 'var _customizePartialRefreshExports = %s;', wp_json_encode( $exports ) ) );196 wp_print_inline_script_tag( sprintf( 'var _customizePartialRefreshExports = %s;', wp_json_encode( $exports, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) ); 197 197 } 198 198 -
trunk/src/wp-includes/general-template.php
r60331 r60681 4067 4067 } 4068 4068 4069 wp_add_inline_script( 'code-editor', sprintf( 'jQuery.extend( wp.codeEditor.defaultSettings, %s );', wp_json_encode( $settings ) ) );4069 wp_add_inline_script( 'code-editor', sprintf( 'jQuery.extend( wp.codeEditor.defaultSettings, %s );', wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) ); 4070 4070 4071 4071 /** -
trunk/src/wp-includes/media.php
r60678 r60681 3275 3275 </ol> 3276 3276 </noscript> 3277 <script type="application/json" class="wp-playlist-script"><?php echo wp_json_encode( $data ); ?></script>3277 <script type="application/json" class="wp-playlist-script"><?php echo wp_json_encode( $data, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?></script> 3278 3278 </div> 3279 3279 <?php … … 4436 4436 ); 4437 4437 4438 $script = 'var _wpPluploadSettings = ' . wp_json_encode( $settings ) . ';';4438 $script = 'var _wpPluploadSettings = ' . wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ';'; 4439 4439 4440 4440 if ( $data ) { -
trunk/src/wp-includes/script-loader.php
r60522 r60681 160 160 'LLLL' => null, 161 161 ), 162 ) 162 ), 163 JSON_HEX_TAG | JSON_UNESCAPED_SLASHES 163 164 ) 164 165 ), … … 385 386 wp.data.dispatch( preferencesStore ).setPersistenceLayer( persistenceLayer ); 386 387 } ) ();', 387 wp_json_encode( $preload_data ),388 wp_json_encode( $preload_data, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 388 389 $user_id 389 390 ) … … 478 479 'abbr' => $timezone_abbr, 479 480 ), 480 ) 481 ), 482 JSON_HEX_TAG | JSON_UNESCAPED_SLASHES 481 483 ) 482 484 ), … … 641 643 $script = 'window.wpEditorL10n = { 642 644 tinymce: { 643 baseURL: ' . wp_json_encode( includes_url( 'js/tinymce' ) ) . ',645 baseURL: ' . wp_json_encode( includes_url( 'js/tinymce' ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ', 644 646 suffix: ' . ( SCRIPT_DEBUG ? '""' : '".min"' ) . ', 645 647 settings: ' . $init_obj . ', … … 1156 1158 'mejs.yiddish' => __( 'Yiddish' ), 1157 1159 ), 1158 ) 1160 ), 1161 JSON_HEX_TAG | JSON_UNESCAPED_SLASHES 1159 1162 ) 1160 1163 ), … … 2000 2003 'firstDay' => absint( get_option( 'start_of_week' ) ), 2001 2004 'isRTL' => $wp_locale->is_rtl(), 2002 ) 2005 ), 2006 JSON_HEX_TAG | JSON_UNESCAPED_SLASHES 2003 2007 ); 2004 2008 … … 2810 2814 ' wp.blocks.registerBlockStyle( \'%s\', %s );', 2811 2815 $block_name, 2812 wp_json_encode( $block_style )2816 wp_json_encode( $block_style, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 2813 2817 ); 2814 2818 } -
trunk/src/wp-includes/speculative-loading.php
r59881 r60681 248 248 wp_print_inline_script_tag( 249 249 (string) wp_json_encode( 250 $speculation_rules 250 $speculation_rules, 251 JSON_HEX_TAG | JSON_UNESCAPED_SLASHES 251 252 ), 252 253 array( 'type' => 'speculationrules' ) -
trunk/src/wp-includes/theme-previews.php
r57171 r60681 50 50 sprintf( 51 51 'wp.apiFetch.use( wp.apiFetch.createThemePreviewMiddleware( %s ) );', 52 wp_json_encode( sanitize_text_field( wp_unslash( $_GET['wp_theme_preview'] ) ) )52 wp_json_encode( sanitize_text_field( wp_unslash( $_GET['wp_theme_preview'] ) ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 53 53 ), 54 54 'after' … … 71 71 ?> 72 72 <script type="text/javascript"> 73 window.WP_BLOCK_THEME_ACTIVATE_NONCE = <?php echo wp_json_encode( wp_create_nonce( $nonce_handle ) ); ?>;73 window.WP_BLOCK_THEME_ACTIVATE_NONCE = <?php echo wp_json_encode( wp_create_nonce( $nonce_handle ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?>; 74 74 </script> 75 75 <?php -
trunk/src/wp-includes/theme.php
r60499 r60681 3749 3749 ); 3750 3750 3751 $script = 'var _wpCustomizeLoaderSettings = ' . wp_json_encode( $settings ) . ';';3751 $script = 'var _wpCustomizeLoaderSettings = ' . wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) . ';'; 3752 3752 3753 3753 $wp_scripts = wp_scripts(); -
trunk/src/wp-includes/widgets/class-wp-widget-custom-html.php
r59120 r60681 216 216 217 217 wp_enqueue_script( 'custom-html-widgets' ); 218 wp_add_inline_script( 'custom-html-widgets', sprintf( 'wp.customHtmlWidgets.idBases.push( %s );', wp_json_encode( $this->id_base ) ) );218 wp_add_inline_script( 'custom-html-widgets', sprintf( 'wp.customHtmlWidgets.idBases.push( %s );', wp_json_encode( $this->id_base, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) ); 219 219 220 220 if ( empty( $settings ) ) { … … 223 223 ); 224 224 } 225 wp_add_inline_script( 'custom-html-widgets', sprintf( 'wp.customHtmlWidgets.init( %s );', wp_json_encode( $settings ) ), 'after' );225 wp_add_inline_script( 'custom-html-widgets', sprintf( 'wp.customHtmlWidgets.init( %s );', wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ), 'after' ); 226 226 227 227 $l10n = array( … … 234 234 ), 235 235 ); 236 wp_add_inline_script( 'custom-html-widgets', sprintf( 'jQuery.extend( wp.customHtmlWidgets.l10n, %s );', wp_json_encode( $l10n ) ), 'after' );236 wp_add_inline_script( 'custom-html-widgets', sprintf( 'jQuery.extend( wp.customHtmlWidgets.l10n, %s );', wp_json_encode( $l10n, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ), 'after' ); 237 237 } 238 238 -
trunk/src/wp-includes/widgets/class-wp-widget-media-audio.php
r56597 r60681 161 161 sprintf( 162 162 'wp.mediaWidgets.modelConstructors[ %s ].prototype.schema = %s;', 163 wp_json_encode( $this->id_base ),164 wp_json_encode( $exported_schema )163 wp_json_encode( $this->id_base, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 164 wp_json_encode( $exported_schema, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 165 165 ) 166 166 ); … … 173 173 wp.mediaWidgets.controlConstructors[ %1$s ].prototype.l10n = _.extend( {}, wp.mediaWidgets.controlConstructors[ %1$s ].prototype.l10n, %3$s ); 174 174 ', 175 wp_json_encode( $this->id_base ),176 wp_json_encode( $this->widget_options['mime_type'] ),177 wp_json_encode( $this->l10n )175 wp_json_encode( $this->id_base, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 176 wp_json_encode( $this->widget_options['mime_type'], JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 177 wp_json_encode( $this->l10n, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 178 178 ) 179 179 ); -
trunk/src/wp-includes/widgets/class-wp-widget-media-gallery.php
r60325 r60681 149 149 sprintf( 150 150 'wp.mediaWidgets.modelConstructors[ %s ].prototype.schema = %s;', 151 wp_json_encode( $this->id_base ),152 wp_json_encode( $exported_schema )151 wp_json_encode( $this->id_base, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 152 wp_json_encode( $exported_schema, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 153 153 ) 154 154 ); … … 161 161 _.extend( wp.mediaWidgets.controlConstructors[ %1$s ].prototype.l10n, %3$s ); 162 162 ', 163 wp_json_encode( $this->id_base ),164 wp_json_encode( $this->widget_options['mime_type'] ),165 wp_json_encode( $this->l10n )163 wp_json_encode( $this->id_base, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 164 wp_json_encode( $this->widget_options['mime_type'], JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 165 wp_json_encode( $this->l10n, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 166 166 ) 167 167 ); -
trunk/src/wp-includes/widgets/class-wp-widget-media-image.php
r59120 r60681 324 324 sprintf( 325 325 'wp.mediaWidgets.modelConstructors[ %s ].prototype.schema = %s;', 326 wp_json_encode( $this->id_base ),327 wp_json_encode( $exported_schema )326 wp_json_encode( $this->id_base, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 327 wp_json_encode( $exported_schema, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 328 328 ) 329 329 ); … … 336 336 wp.mediaWidgets.controlConstructors[ %1$s ].prototype.l10n = _.extend( {}, wp.mediaWidgets.controlConstructors[ %1$s ].prototype.l10n, %3$s ); 337 337 ', 338 wp_json_encode( $this->id_base ),339 wp_json_encode( $this->widget_options['mime_type'] ),340 wp_json_encode( $this->l10n )338 wp_json_encode( $this->id_base, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 339 wp_json_encode( $this->widget_options['mime_type'], JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 340 wp_json_encode( $this->l10n, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 341 341 ) 342 342 ); -
trunk/src/wp-includes/widgets/class-wp-widget-media-video.php
r56597 r60681 200 200 sprintf( 201 201 'wp.mediaWidgets.modelConstructors[ %s ].prototype.schema = %s;', 202 wp_json_encode( $this->id_base ),203 wp_json_encode( $exported_schema )202 wp_json_encode( $this->id_base, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 203 wp_json_encode( $exported_schema, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 204 204 ) 205 205 ); … … 212 212 wp.mediaWidgets.controlConstructors[ %1$s ].prototype.l10n = _.extend( {}, wp.mediaWidgets.controlConstructors[ %1$s ].prototype.l10n, %3$s ); 213 213 ', 214 wp_json_encode( $this->id_base ),215 wp_json_encode( $this->widget_options['mime_type'] ),216 wp_json_encode( $this->l10n )214 wp_json_encode( $this->id_base, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 215 wp_json_encode( $this->widget_options['mime_type'], JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ), 216 wp_json_encode( $this->l10n, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) 217 217 ) 218 218 ); -
trunk/src/wp-includes/widgets/class-wp-widget-text.php
r59696 r60681 436 436 wp_enqueue_media(); 437 437 wp_enqueue_script( 'text-widgets' ); 438 wp_add_inline_script( 'text-widgets', sprintf( 'wp.textWidgets.idBases.push( %s );', wp_json_encode( $this->id_base ) ) );438 wp_add_inline_script( 'text-widgets', sprintf( 'wp.textWidgets.idBases.push( %s );', wp_json_encode( $this->id_base, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) ); 439 439 wp_add_inline_script( 'text-widgets', 'wp.textWidgets.init();', 'after' ); 440 440 } -
trunk/tests/phpunit/tests/dependencies/wpLocalizeScript.php
r58068 r60681 4 4 * @group scripts 5 5 */ 6 class Tests_Dependencies_ LocalizeScript extends WP_UnitTestCase {6 class Tests_Dependencies_wpLocalizeScript extends WP_UnitTestCase { 7 7 /** 8 8 * @var WP_Scripts … … 39 39 ); 40 40 } 41 42 /** 43 * Verifies that wp_localize_script() outputs safe JSON whe harmful data is provided. 44 * 45 * @ticket 63851 46 * @covers ::wp_localize_script 47 */ 48 public function test_wp_localize_script_outputs_safe_json() { 49 add_theme_support( 'html5', array( 'script' ) ); 50 51 $path = '/test.js'; 52 $base_url = site_url( $path ); 53 54 wp_enqueue_script( 'test-script', $path, array(), null ); 55 wp_localize_script( 'test-script', 'testData', array( '<!--' => '<script>' ) ); 56 57 $output = get_echo( 'wp_print_scripts' ); 58 59 $expected = "<script id=\"test-script-js-extra\">\nvar testData = {\"\\u003C!--\":\"\\u003Cscript\\u003E\"};\n</script>\n"; 60 $expected .= "<script src=\"{$base_url}\" id=\"test-script-js\"></script>\n"; 61 62 $this->assertEqualHTML( $expected, $output ); 63 } 41 64 }
Note: See TracChangeset
for help on using the changeset viewer.