diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php index 7ca5191a0f162..32cb30b6afb82 100644 --- a/src/wp-includes/html-api/class-wp-html-tag-processor.php +++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php @@ -1475,7 +1475,7 @@ private function skip_rcdata( string $tag_name ): bool { * though "textarea" is found within the text. */ $c = $html[ $at ]; - if ( ' ' !== $c && "\t" !== $c && "\r" !== $c && "\n" !== $c && '/' !== $c && '>' !== $c ) { + if ( ' ' !== $c && "\t" !== $c && "\f" !== $c && "\r" !== $c && "\n" !== $c && '/' !== $c && '>' !== $c ) { continue; } diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index 66e01dbdbed3e..8733f5718ba6c 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -2369,6 +2369,52 @@ public static function data_script_tag(): Generator { yield 'Script tag double-escaped with ", false ); } + /** + * Ensures that tag-name-terminating characters close RCDATA and RAWTEXT elements. + * + * @dataProvider data_rcdata_and_rawtext_tag_name_terminators + * + * @param string $tag_name The RCDATA or RAWTEXT tag name. + * @param string $tag_name_terminator The tag-name-terminating character. + */ + public function test_rcdata_and_rawtext_end_tags_accept_tag_name_terminators( string $tag_name, string $tag_name_terminator ): void { + $end_tag_closer = '>' === $tag_name_terminator ? '' : '>'; + $processor = new WP_HTML_Tag_Processor( "<{$tag_name}>content{$tag_name}{$tag_name_terminator}{$end_tag_closer}