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 304298170d29d..37e949b7af631 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 @@ -2616,6 +2616,10 @@ public function get_modifiable_text() { $text = substr( $this->html, $at, $length ); $text = html_entity_decode( $text, ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE ); + if ( empty( $text ) ) { + return ''; + } + /* * PRE and TEXTAREA skip a leading newline, but this newline may not be a `\n`. * It could be a character reference, such as ``. diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor-token-scanning.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor-token-scanning.php index ecee4596b0045..b105b586aab0e 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor-token-scanning.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor-token-scanning.php @@ -151,7 +151,8 @@ public function test_basic_assertion_script_element() { * @covers WP_HTML_Tag_Processor::next_token */ public function test_basic_assertion_textarea_element() { - $processor = WP_HTML_Processor::create_fragment( << Is > XHTML? @@ -203,7 +204,8 @@ public function test_basic_assertion_textarea_element() { * @covers WP_HTML_Tag_Processor::next_token */ public function test_basic_assertion_title_element() { - $processor = WP_HTML_Processor::create_fragment( << Is > XHTML? @@ -252,7 +254,8 @@ public function test_basic_assertion_title_element() { * @param string $tag_name The name of the RAWTEXT tag to test. */ public function test_basic_assertion_rawtext_elements( $tag_name ) { - $processor = WP_HTML_Processor::create_fragment( << Is > XHTML?