From cf7330c2223ac39edc380edba3fcdfb587dcb1ec Mon Sep 17 00:00:00 2001 From: jonsurrell Date: Thu, 24 Jul 2025 06:49:29 +0000 Subject: [PATCH] HTML API: Simplify META tag processing. META tag processing can be simplified in most cases. Add an early check and return to avoid additional processing. Developed in https://github.com/WordPress/wordpress-develop/pull/9231. Props jonsurrell, dmsnell. See #63738. Built from https://develop.svn.wordpress.org/trunk@60502 git-svn-id: http://core.svn.wordpress.org/trunk@59838 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/html-api/class-wp-html-processor.php | 10 +++++++--- wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/wp-includes/html-api/class-wp-html-processor.php b/wp-includes/html-api/class-wp-html-processor.php index d64574e2a8..ba03ff44d7 100644 --- a/wp-includes/html-api/class-wp-html-processor.php +++ b/wp-includes/html-api/class-wp-html-processor.php @@ -1760,6 +1760,11 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor { case '+META': $this->insert_html_element( $this->state->current_token ); + // All following conditions depend on "tentative" encoding confidence. + if ( 'tentative' !== $this->state->encoding_confidence ) { + return true; + } + /* * > If the active speculative HTML parser is null, then: * > - If the element has a charset attribute, and getting an encoding from @@ -1767,7 +1772,7 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor { * > tentative, then change the encoding to the resulting encoding. */ $charset = $this->get_attribute( 'charset' ); - if ( is_string( $charset ) && 'tentative' === $this->state->encoding_confidence ) { + if ( is_string( $charset ) ) { $this->bail( 'Cannot yet process META tags with charset to determine encoding.' ); } @@ -1784,8 +1789,7 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor { if ( is_string( $http_equiv ) && is_string( $content ) && - 0 === strcasecmp( $http_equiv, 'Content-Type' ) && - 'tentative' === $this->state->encoding_confidence + 0 === strcasecmp( $http_equiv, 'Content-Type' ) ) { $this->bail( 'Cannot yet process META tags with http-equiv Content-Type to determine encoding.' ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index bfd7384264..cbffc2b53d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.9-alpha-60501'; +$wp_version = '6.9-alpha-60502'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.