Skip to content

Commit f6b028d

Browse files
committed
Trac #64428: Restore CDATA condition and keep explicitly set script types.
1 parent 9cbb060 commit f6b028d

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

src/wp-includes/script-loader.php

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,12 +2205,11 @@ function _print_scripts() {
22052205
$zip = 'gzip';
22062206
}
22072207

2208-
$concat = trim( $wp_scripts->concat, ', ' );
2209-
$type_attr = '';
2208+
$concat = trim( $wp_scripts->concat, ', ' );
22102209

22112210
if ( $concat ) {
22122211
if ( ! empty( $wp_scripts->print_code ) ) {
2213-
echo "\n<script{$type_attr}>\n";
2212+
echo "\n<script>\n";
22142213
echo "/* <![CDATA[ */\n"; // Not needed in HTML 5.
22152214
echo $wp_scripts->print_code;
22162215
echo sprintf( "\n//# sourceURL=%s\n", rawurlencode( 'js-inline-concat-' . $concat ) );
@@ -2226,7 +2225,7 @@ function _print_scripts() {
22262225
}
22272226

22282227
$src = $wp_scripts->base_url . "/wp-admin/load-scripts.php?c={$zip}" . $concatenated . '&ver=' . $wp_scripts->default_version;
2229-
echo "<script{$type_attr} src='" . esc_attr( $src ) . "'></script>\n";
2228+
echo "<script src='" . esc_attr( $src ) . "'></script>\n";
22302229
}
22312230

22322231
if ( ! empty( $wp_scripts->print_html ) ) {
@@ -2398,8 +2397,7 @@ function _print_styles() {
23982397
$zip = 'gzip';
23992398
}
24002399

2401-
$concat = trim( $wp_styles->concat, ', ' );
2402-
$type_attr = '';
2400+
$concat = trim( $wp_styles->concat, ', ' );
24032401

24042402
if ( $concat ) {
24052403
$dir = $wp_styles->text_direction;
@@ -2414,10 +2412,10 @@ function _print_styles() {
24142412
}
24152413

24162414
$href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}" . $concatenated . '&ver=' . $ver;
2417-
echo "<link rel='stylesheet' href='" . esc_attr( $href ) . "'{$type_attr} media='all' />\n";
2415+
echo "<link rel='stylesheet' href='" . esc_attr( $href ) . "' media='all' />\n";
24182416

24192417
if ( ! empty( $wp_styles->print_code ) ) {
2420-
echo "<style{$type_attr}>\n";
2418+
echo "<style>\n";
24212419
echo $wp_styles->print_code;
24222420
echo sprintf( "\n/*# sourceURL=%s */", rawurlencode( $concat_source_url ) );
24232421
echo "\n</style>\n";
@@ -2905,9 +2903,6 @@ function wp_sanitize_script_attributes( $attributes ) {
29052903
* @return string String containing `<script>` opening and closing tags.
29062904
*/
29072905
function wp_get_script_tag( $attributes ) {
2908-
if ( isset( $attributes['type'] ) && 'text/javascript' === $attributes['type'] ) {
2909-
unset( $attributes['type'] );
2910-
}
29112906
/**
29122907
* Filters attributes to be added to a script tag.
29132908
*
@@ -2949,10 +2944,6 @@ function wp_print_script_tag( $attributes ) {
29492944
* @return string String containing inline JavaScript code wrapped around `<script>` tag.
29502945
*/
29512946
function wp_get_inline_script_tag( $data, $attributes = array() ) {
2952-
if ( isset( $attributes['type'] ) && 'text/javascript' === $attributes['type'] ) {
2953-
unset( $attributes['type'] );
2954-
}
2955-
29562947
/*
29572948
* XHTML extracts the contents of the SCRIPT element and then the XML parser
29582949
* decodes character references and other syntax elements. This can lead to
@@ -2978,12 +2969,15 @@ function wp_get_inline_script_tag( $data, $attributes = array() ) {
29782969
* @see https://www.w3.org/TR/xhtml1/#h-4.8
29792970
*/
29802971
if (
2981-
! isset( $attributes['type'] ) ||
2982-
'module' === $attributes['type'] ||
2983-
str_contains( $attributes['type'], 'javascript' ) ||
2984-
str_contains( $attributes['type'], 'ecmascript' ) ||
2985-
str_contains( $attributes['type'], 'jscript' ) ||
2986-
str_contains( $attributes['type'], 'livescript' )
2972+
! current_theme_supports( 'html5', 'script' ) &&
2973+
(
2974+
! isset( $attributes['type'] ) ||
2975+
'module' === $attributes['type'] ||
2976+
str_contains( $attributes['type'], 'javascript' ) ||
2977+
str_contains( $attributes['type'], 'ecmascript' ) ||
2978+
str_contains( $attributes['type'], 'jscript' ) ||
2979+
str_contains( $attributes['type'], 'livescript' )
2980+
)
29872981
) {
29882982
/*
29892983
* If the string `]]>` exists within the JavaScript it would break

0 commit comments

Comments
 (0)