Skip to content

Commit 3bed173

Browse files
committed
Add basic conformance tests
1 parent 1436205 commit 3bed173

2 files changed

Lines changed: 632 additions & 4 deletions

File tree

src/wp-includes/html-api/class-wp-html-tag-processor.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,20 +2615,27 @@ public function get_token_name() {
26152615
public function get_modifiable_text() {
26162616
$at = $this->text_starts_at;
26172617
$length = $this->text_length;
2618+
$text = substr( $this->html, $at, $length );
2619+
$text = html_entity_decode( $text, ENT_QUOTES | ENT_HTML5 | ENT_SUBSTITUTE );
26182620

2621+
/*
2622+
* PRE and TEXTAREA skip a leading newline, but this newline may not be a `\n`.
2623+
* It could be a character reference, such as `<textarea>&#x0a;Content</textarea>`.
2624+
* For these cases it's important to first decode the text content before checking
2625+
* for a leading newline and removing it.
2626+
*/
26192627
if ( self::STATE_MATCHED_TAG === $this->parser_state ) {
26202628
switch ( $this->get_tag() ) {
26212629
case 'PRE':
26222630
case 'TEXTAREA':
2623-
if ( "\n" === $this->html[ $at ] ) {
2624-
++$at;
2625-
--$length;
2631+
if ( "\n" === $text[0] ) {
2632+
return substr( $text, 1 );
26262633
}
26272634
break;
26282635
}
26292636
}
26302637

2631-
return substr( $this->html, $at, $length );
2638+
return $text;
26322639
}
26332640

26342641
/**

0 commit comments

Comments
 (0)