From a3abf9c89f6aa4ceb05fe8d0f7e487204b959caf Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 23 Jan 2024 17:56:12 +0000 Subject: [PATCH] Script Loader: Only emit CDATA wrapper comments in `wp_get_inline_script_tag()` for JavaScript. This avoids erroneously adding CDATA wrapper comments for non-JavaScript scripts, including those for JSON such as the `importmap` for script modules in #56313. Props westonruter, flixos90, mukesh27, dmsnell. See #56313. Fixes #60320. Built from https://develop.svn.wordpress.org/trunk@57341 git-svn-id: http://core.svn.wordpress.org/trunk@56847 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/script-loader.php | 12 +++++++++++- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 6425afe874..a04c580274 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -2879,7 +2879,17 @@ function wp_get_inline_script_tag( $javascript, $attributes = array() ) { * * @see https://www.w3.org/TR/xhtml1/#h-4.8 */ - if ( ! $is_html5 ) { + if ( + ! $is_html5 && + ( + ! isset( $attributes['type'] ) || + 'module' === $attributes['type'] || + str_contains( $attributes['type'], 'javascript' ) || + str_contains( $attributes['type'], 'ecmascript' ) || + str_contains( $attributes['type'], 'jscript' ) || + str_contains( $attributes['type'], 'livescript' ) + ) + ) { /* * If the string `]]>` exists within the JavaScript it would break * out of any wrapping CDATA section added here, so to start, it's diff --git a/wp-includes/version.php b/wp-includes/version.php index 2d38dd4a82..4d3a6f710b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5-alpha-57340'; +$wp_version = '6.5-alpha-57341'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.