Make WordPress Core

Changeset 62666


Ignore:
Timestamp:
07/08/2026 11:15:31 AM (2 months ago)
Author:
jonsurrell
Message:

HTML API: Apply HTML specification change to DOCTYPE parsing.

The HTML standard was updated to remove a distinction between empty and missing SYSTEM identifiers for the purposes of determining the mode of a document. See https://github.com/whatwg/html/issues/12023.

Developed in https://github.com/WordPress/wordpress-develop/pull/12382

Props jonsurrell, dmsnell.
Fixes #64504.

Location:
trunk
Files:
2 edited

Legend:

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

    r62507 r62666  
    5050 *
    5151 * @since 6.7.0
     52 * @since 7.1.0 Spec update: missing and empty SYSTEM identifiers are handled
     53 *              the same for determining the document mode.
    5254 *
    5355 * @access private
     
    230232                 * > The system identifier and public identifier strings must be compared...
    231233                 * > in an ASCII case-insensitive manner.
    232                  * >
    233                  * > A system identifier whose value is the empty string is not considered missing
    234                  * > for the purposes of the conditions above.
    235                  */
    236                 $system_identifier_is_missing = null === $system_identifier;
    237                 $public_identifier            = null === $public_identifier ? '' : strtolower( $public_identifier );
    238                 $system_identifier            = null === $system_identifier ? '' : strtolower( $system_identifier );
     234                 */
     235                $public_identifier = null === $public_identifier ? '' : strtolower( $public_identifier );
     236                $system_identifier = null === $system_identifier ? '' : strtolower( $system_identifier );
    239237
    240238                /*
     
    336334
    337335                /*
    338                  * > The system identifier is missing and the public identifier starts with…
     336                 * > The system identifier is missing or the empty string, and the
     337                 * > public identifier starts with…
    339338                 */
    340339                if (
    341                         $system_identifier_is_missing && (
     340                        '' === $system_identifier && (
    342341                                str_starts_with( $public_identifier, '-//w3c//dtd html 4.01 frameset//' ) ||
    343342                                str_starts_with( $public_identifier, '-//w3c//dtd html 4.01 transitional//' )
     
    365364
    366365                /*
    367                  * > The system identifier is not missing and the public identifier starts with…
     366                 * > The system identifier is neither missing nor the empty string, and the
     367                 * > public identifier starts with…
    368368                 */
    369369                if (
    370                         ! $system_identifier_is_missing && (
     370                        '' !== $system_identifier && (
    371371                                str_starts_with( $public_identifier, '-//w3c//dtd html 4.01 frameset//' ) ||
    372372                                str_starts_with( $public_identifier, '-//w3c//dtd html 4.01 transitional//' )
  • trunk/tests/phpunit/tests/html-api/wpHtmlDoctypeInfo.php

    r60647 r62666  
    8888                        'Bogus characters instead of SYSTEM quote after public' => array( "<!DOCTYPE html PUBLIC ''x''>", 'quirks', 'html', '' ),
    8989                        'Special quirks mode if system unset'       => array( '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//">', 'quirks', 'html', '-//W3C//DTD HTML 4.01 Frameset//' ),
    90                         'Special limited-quirks mode if system set' => array( '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//" "">', 'limited-quirks', 'html', '-//W3C//DTD HTML 4.01 Frameset//', '' ),
     90                        'Special quirks mode if system empty'       => array( '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//" "">', 'quirks', 'html', '-//W3C//DTD HTML 4.01 Frameset//', '' ),
     91                        'Special limited-quirks mode if system is non-empty' => array( '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//" "non-empty">', 'limited-quirks', 'html', '-//W3C//DTD HTML 4.01 Frameset//', 'non-empty' ),
    9192                );
    9293        }
Note: See TracChangeset for help on using the changeset viewer.