diff --git a/src/wp-includes/html-api/class-wp-html-doctype-info.php b/src/wp-includes/html-api/class-wp-html-doctype-info.php index a5aae3c5ec268..75b16056fb185 100644 --- a/src/wp-includes/html-api/class-wp-html-doctype-info.php +++ b/src/wp-includes/html-api/class-wp-html-doctype-info.php @@ -229,13 +229,9 @@ private function __construct( * > * > The system identifier and public identifier strings must be compared... * > in an ASCII case-insensitive manner. - * > - * > A system identifier whose value is the empty string is not considered missing - * > for the purposes of the conditions above. */ - $system_identifier_is_missing = null === $system_identifier; - $public_identifier = null === $public_identifier ? '' : strtolower( $public_identifier ); - $system_identifier = null === $system_identifier ? '' : strtolower( $system_identifier ); + $public_identifier = null === $public_identifier ? '' : strtolower( $public_identifier ); + $system_identifier = null === $system_identifier ? '' : strtolower( $system_identifier ); /* * > The public identifier is set to… @@ -335,10 +331,11 @@ private function __construct( } /* - * > The system identifier is missing and the public identifier starts with… + * > The system identifier is missing or the empty string, and the + * > public identifier starts with… */ if ( - $system_identifier_is_missing && ( + '' === $system_identifier && ( str_starts_with( $public_identifier, '-//w3c//dtd html 4.01 frameset//' ) || str_starts_with( $public_identifier, '-//w3c//dtd html 4.01 transitional//' ) ) @@ -364,10 +361,11 @@ private function __construct( } /* - * > The system identifier is not missing and the public identifier starts with… + * > The system identifier is neither missing nor the empty string, and the + * > public identifier starts with… */ if ( - ! $system_identifier_is_missing && ( + '' !== $system_identifier && ( str_starts_with( $public_identifier, '-//w3c//dtd html 4.01 frameset//' ) || str_starts_with( $public_identifier, '-//w3c//dtd html 4.01 transitional//' ) ) diff --git a/tests/phpunit/tests/html-api/wpHtmlDoctypeInfo.php b/tests/phpunit/tests/html-api/wpHtmlDoctypeInfo.php index 40400984e5cff..2abc1cdc1ca5a 100644 --- a/tests/phpunit/tests/html-api/wpHtmlDoctypeInfo.php +++ b/tests/phpunit/tests/html-api/wpHtmlDoctypeInfo.php @@ -87,7 +87,8 @@ public static function data_parseable_raw_doctypes(): array { 'Emoji' => array( '', 'quirks', "\u{1F3F4}\u{E0067}\u{E0062}\u{E0065}\u{E006E}\u{E0067}\u{E007F}", '🔥', '😈' ), 'Bogus characters instead of SYSTEM quote after public' => array( "", 'quirks', 'html', '' ), 'Special quirks mode if system unset' => array( '', 'quirks', 'html', '-//W3C//DTD HTML 4.01 Frameset//' ), - 'Special limited-quirks mode if system set' => array( '', 'limited-quirks', 'html', '-//W3C//DTD HTML 4.01 Frameset//', '' ), + 'Special quirks mode if system empty' => array( '', 'quirks', 'html', '-//W3C//DTD HTML 4.01 Frameset//', '' ), + 'Special limited-quirks mode if system is non-empty' => array( '', 'limited-quirks', 'html', '-//W3C//DTD HTML 4.01 Frameset//', 'non-empty' ), ); }