Skip to content

Commit

Permalink
Fix + WPCS
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed Jan 11, 2024
1 parent 2b6352a commit 103a556
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/wp-includes/html-api/class-wp-html-tag-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<textarea>&#x0a;Content</textarea>`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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( <<<HTML
$processor = WP_HTML_Processor::create_fragment(
<<<HTML
<textarea rows=30 cols="80">
Is <HTML> &gt; XHTML?
</textarea>
Expand Down Expand Up @@ -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( <<<HTML
$processor = WP_HTML_Processor::create_fragment(
<<<HTML
<title class="multi-line-title">
Is <HTML> &gt; XHTML?
</title>
Expand Down Expand Up @@ -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( <<<HTML
$processor = WP_HTML_Processor::create_fragment(
<<<HTML
<{$tag_name} class="multi-line-title">
Is <HTML> &gt; XHTML?
</{$tag_name}>
Expand Down

0 comments on commit 103a556

Please sign in to comment.