diff --git a/wp-includes/template.php b/wp-includes/template.php index f799113e9c..f17307e19d 100644 --- a/wp-includes/template.php +++ b/wp-includes/template.php @@ -926,13 +926,24 @@ function wp_finalize_template_enhancement_output_buffer( string $output, int $ph $is_html_content_type = null; $html_content_types = array( 'text/html', 'application/xhtml+xml' ); foreach ( headers_list() as $header ) { - $header_parts = preg_split( '/\s*[:;]\s*/', strtolower( $header ) ); + $header_parts = explode( ':', strtolower( $header ), 2 ); if ( - is_array( $header_parts ) && - count( $header_parts ) >= 2 && + count( $header_parts ) === 2 && 'content-type' === $header_parts[0] ) { - $is_html_content_type = in_array( $header_parts[1], $html_content_types, true ); + /* + * This is looking for very specific content types, therefore it + * doesn’t need to fully parse the header’s value. Instead, it needs + * only assert that the content type is one of the static HTML types. + * + * Example: + * + * Content-Type: text/html; charset=utf8 + * Content-Type: text/html ;charset=latin4 + * Content-Type:application/xhtml+xml + */ + $media_type = trim( strtok( $header_parts[1], ';' ), " \t" ); + $is_html_content_type = in_array( $media_type, $html_content_types, true ); break; // PHP only sends the first Content-Type header in the list. } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 38e78755e5..1209fd5797 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.9-alpha-60972'; +$wp_version = '6.9-alpha-60973'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.