From 103a556b6095fe61843719933db7ce2d0688ec7a Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Wed, 10 Jan 2024 12:05:45 -0500 Subject: [PATCH] Fix + WPCS --- src/wp-includes/html-api/class-wp-html-tag-processor.php | 4 ++++ .../tests/html-api/wpHtmlTagProcessor-token-scanning.php | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) 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?