Make WordPress Core

Changeset 60502


Ignore:
Timestamp:
07/24/2025 06:47:41 AM (14 months ago)
Author:
jonsurrell
Message:

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.

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/html-api/class-wp-html-processor.php

    r59747 r60502  
    17611761                                $this->insert_html_element( $this->state->current_token );
    17621762
     1763                                // All following conditions depend on "tentative" encoding confidence.
     1764                                if ( 'tentative' !== $this->state->encoding_confidence ) {
     1765                                        return true;
     1766                                }
     1767
    17631768                                /*
    17641769                                 * > If the active speculative HTML parser is null, then:
     
    17681773                                 */
    17691774                                $charset = $this->get_attribute( 'charset' );
    1770                                 if ( is_string( $charset ) && 'tentative' === $this->state->encoding_confidence ) {
     1775                                if ( is_string( $charset ) ) {
    17711776                                        $this->bail( 'Cannot yet process META tags with charset to determine encoding.' );
    17721777                                }
     
    17851790                                        is_string( $http_equiv ) &&
    17861791                                        is_string( $content ) &&
    1787                                         0 === strcasecmp( $http_equiv, 'Content-Type' ) &&
    1788                                         'tentative' === $this->state->encoding_confidence
     1792                                        0 === strcasecmp( $http_equiv, 'Content-Type' )
    17891793                                ) {
    17901794                                        $this->bail( 'Cannot yet process META tags with http-equiv Content-Type to determine encoding.' );
Note: See TracChangeset for help on using the changeset viewer.