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
This commit is contained in:
jonsurrell
2025-07-24 06:49:29 +00:00
parent 7cabf198f5
commit cf7330c222
2 changed files with 8 additions and 4 deletions

View File

@@ -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.' );
}

View File

@@ -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.