Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/wp-includes/html-api/class-wp-html-doctype-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -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…
Expand Down Expand Up @@ -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//' )
)
Expand All @@ -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//' )
)
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/tests/html-api/wpHtmlDoctypeInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public static function data_parseable_raw_doctypes(): array {
'Emoji' => array( '<!DOCTYPE 🏴󠁧󠁢󠁥󠁮󠁧󠁿 PUBLIC "🔥" "😈">', 'quirks', "\u{1F3F4}\u{E0067}\u{E0062}\u{E0065}\u{E006E}\u{E0067}\u{E007F}", '🔥', '😈' ),
'Bogus characters instead of SYSTEM quote after public' => array( "<!DOCTYPE html PUBLIC ''x''>", 'quirks', 'html', '' ),
'Special quirks mode if system unset' => array( '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//">', 'quirks', 'html', '-//W3C//DTD HTML 4.01 Frameset//' ),
'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//', '' ),
'Special quirks mode if system empty' => array( '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//" "">', 'quirks', 'html', '-//W3C//DTD HTML 4.01 Frameset//', '' ),
'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' ),
);
}

Expand Down
Loading