Changeset 57489
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/html-api/class-wp-html-tag-processor.php
r57348 r57489 1513 1513 $at = strpos( $html, '<', $at ); 1514 1514 1515 if ( $at > $was_at ) {1516 $this->parser_state = self::STATE_TEXT_NODE;1517 $this->token_starts_at = $was_at;1518 $this->token_length = $at - $was_at;1519 $this->text_starts_at = $was_at;1520 $this->text_length = $this->token_length;1521 $this->bytes_already_parsed = $at;1522 return true;1523 }1524 1525 1515 /* 1526 1516 * This does not imply an incomplete parse; it indicates that there … … 1534 1524 $this->text_length = $this->token_length; 1535 1525 $this->bytes_already_parsed = strlen( $html ); 1526 return true; 1527 } 1528 1529 if ( $at > $was_at ) { 1530 /* 1531 * A "<" has been found in the document. That may be the start of another node, or 1532 * it may be an "ivalid-first-character-of-tag-name" error. If this is not the start 1533 * of another node the "<" should be included in this text node and another 1534 * termination point should be found for the text node. 1535 * 1536 * @see https://html.spec.whatwg.org/#tag-open-state 1537 */ 1538 if ( strlen( $html ) > $at + 1 ) { 1539 $next_character = $html[ $at + 1 ]; 1540 $at_another_node = 1541 '!' === $next_character || 1542 '/' === $next_character || 1543 '?' === $next_character || 1544 ( 'A' <= $next_character && $next_character <= 'z' ); 1545 if ( ! $at_another_node ) { 1546 ++$at; 1547 continue; 1548 } 1549 } 1550 1551 $this->parser_state = self::STATE_TEXT_NODE; 1552 $this->token_starts_at = $was_at; 1553 $this->token_length = $at - $was_at; 1554 $this->text_starts_at = $was_at; 1555 $this->text_length = $this->token_length; 1556 $this->bytes_already_parsed = $at; 1536 1557 return true; 1537 1558 } -
trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php
r57348 r57489 2716 2716 $this->assertFalse( $result, 'Did not handle "</ " html properly.' ); 2717 2717 } 2718 2719 /** 2720 * Ensures that non-tag syntax starting with `<` is consumed inside a text node. 2721 * 2722 * @ticket 60385 2723 */ 2724 public function test_single_text_node_with_taglike_text() { 2725 $p = new WP_HTML_Tag_Processor( 'test< /A>' ); 2726 $p->next_token(); 2727 $this->assertSame( '#text', $p->get_token_type(), 'Did not find text node.' ); 2728 $this->assertSame( 'test< /A>', $p->get_modifiable_text(), 'Did not find complete text node.' ); 2729 } 2718 2730 }
Note: See TracChangeset
for help on using the changeset viewer.