Skip to content

Commit da53752

Browse files
committed
Add failing test for deep nesting
1 parent 2c9a17d commit da53752

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/phpunit/tests/html-api/wpHtmlProcessor.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,4 +1079,23 @@ public function test_next_tag_lowercase_tag_name() {
10791079
$processor = WP_HTML_Processor::create_fragment( '<svg><RECT>' );
10801080
$this->assertTrue( $processor->next_tag( array( 'tag_name' => 'rect' ) ) );
10811081
}
1082+
1083+
/**
1084+
* Ensure that the processor does not throw errors in cases of extreme HTML nesting.
1085+
*
1086+
* @ticket TBD
1087+
*
1088+
* @expectedIncorrectUsage WP_HTML_Tag_Processor::set_bookmark
1089+
*/
1090+
public function test_deep_nesting_fails_process_without_error() {
1091+
$html = str_repeat( '<i>', WP_HTML_Processor::MAX_BOOKMARKS * 2 );
1092+
$processor = WP_HTML_Processor::create_fragment( $html );
1093+
1094+
// The fragment parser starts with a few context tokens already bookmarked.
1095+
$reached_tokens = ( fn() => count( $this->bookmarks ) )->call( $processor );
1096+
while ( $processor->next_token() ) {
1097+
++$reached_tokens;
1098+
}
1099+
$this->assertSame( WP_HTML_Processor::MAX_BOOKMARKS, $reached_tokens );
1100+
}
10821101
}

0 commit comments

Comments
 (0)