Skip to content

Commit 858012e

Browse files
committed
Reapply "Fix json encode that may break enclosing script tag"
This reverts commit e3d001080fcf6c2f546a165f3c9800a54dd9779e.
1 parent 42d0f3b commit 858012e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/wp-includes/block-editor.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,11 +762,16 @@ function block_editor_rest_api_preload( array $preload_paths, $block_editor_cont
762762
$wp_scripts = $backup_wp_scripts;
763763
$wp_styles = $backup_wp_styles;
764764

765+
$json_encode_flags = JSON_HEX_TAG | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_LINE_TERMINATORS;
766+
if ( ! is_utf8_charset() ) {
767+
$json_encode_flags = JSON_HEX_TAG | JSON_UNESCAPED_SLASHES;
768+
}
769+
765770
wp_add_inline_script(
766771
'wp-api-fetch',
767772
sprintf(
768773
'wp.apiFetch.use( wp.apiFetch.createPreloadingMiddleware( %s ) );',
769-
wp_json_encode( $preload_data )
774+
wp_json_encode( $preload_data, $json_encode_flags )
770775
),
771776
'after'
772777
);

0 commit comments

Comments
 (0)