HTML API: Fix splitting single text node.

When `next_token()` was introduced, it brought a subtle bug. When encountering a `<` in the HTML stream which did not lead to a tag or comment or other token, it was treating the full text span to that point as one text node, and the following span another text node.

The entire span should be one text node.

In this patch the Tag Processor properly detects this scenario and combines the spans into one text node.

Follow-up to [57348]

Props jonsurrell
Fixes #60385



git-svn-id: https://develop.svn.wordpress.org/trunk@57489 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dennis Snell
2024-01-30 22:07:42 +00:00
parent a172e31c9e
commit 0b800d7e58
2 changed files with 43 additions and 10 deletions
@@ -2715,4 +2715,16 @@ HTML
$result = $p->next_tag();
$this->assertFalse( $result, 'Did not handle "</ " html properly.' );
}
/**
* Ensures that non-tag syntax starting with `<` is consumed inside a text node.
*
* @ticket 60385
*/
public function test_single_text_node_with_taglike_text() {
$p = new WP_HTML_Tag_Processor( 'test< /A>' );
$p->next_token();
$this->assertSame( '#text', $p->get_token_type(), 'Did not find text node.' );
$this->assertSame( 'test< /A>', $p->get_modifiable_text(), 'Did not find complete text node.' );
}
}