From fc2cadb624459891c34ed21c4fa71d449d709ae5 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 24 May 2024 17:02:15 +0200 Subject: [PATCH 01/15] Add tests for token length --- .../tests/html-api/wpHtmlTagProcessor.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index 824630b33516a..cec84d8f7224d 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -476,6 +476,49 @@ public function test_get_updated_html_applies_updates_to_content_after_seeking_t $this->assertSame( '
', $processor->get_updated_html() ); } + /** + * Ensures that tags start and length are correctly determined. + * + * @ticket 321 + * + * @dataProvider data_tag_start_length + * + * @param string $html + * @param int $start + * @param int $length + */ + public function test_tag_start_length( string $html, int $start, int $length ) { + $processor = new WP_HTML_Tag_Processor( $html ); + + $processor->next_tag( array( 'class_name' => 'target' ) ); + + $start_property = new ReflectionProperty( $processor, 'token_starts_at' ); + $tag_start = $start_property->getValue( $processor ); + + $length_property = new ReflectionProperty( $processor, 'token_length' ); + $tag_length = $length_property->getValue( $processor ); + + $this->assertSame( $start, $tag_start, "Incorrect tag start position found: {$tag_start}." ); + $this->assertSame( $length, $tag_length, "Incorrect tag length found: {$tag_length}." ); + } + + /** + * Data provider. + * + * @return array + */ + public static function data_tag_start_length() { + return array( + 'Simple DIV' => array( '
', 0, 20 ), + 'DIV with attributes' => array( '
', 0, 29 ), + 'Nested DIV' => array( '
', 5, 20 ), + 'DIV after text' => array( 'Initial
', 8, 20 ), + 'DIV after comment' => array( '
', 17, 20 ), + 'DIV before text' => array( '
Trailing', 0, 20 ), + 'DIV before comment' => array( '
', 0, 20 ), + ); + } + /** * @ticket 56299 * From 1f6c861d48cb4cd75ade383d6e1465a2b800544e Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 24 May 2024 17:03:51 +0200 Subject: [PATCH 02/15] Fix tag token length error --- src/wp-includes/html-api/class-wp-html-tag-processor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php index 4597a888b5efe..b79b1f6d1bac8 100644 --- a/src/wp-includes/html-api/class-wp-html-tag-processor.php +++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php @@ -926,8 +926,8 @@ private function base_class_next_token() { return false; } $this->parser_state = self::STATE_MATCHED_TAG; - $this->token_length = $tag_ends_at - $this->token_starts_at; $this->bytes_already_parsed = $tag_ends_at + 1; + $this->token_length = $this->bytes_already_parsed - $this->token_starts_at; /* * For non-DATA sections which might contain text that looks like HTML tags but From 68a3251d307c39467ab85bf739578d15da378d75 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 24 May 2024 18:33:06 +0200 Subject: [PATCH 03/15] Remove off-by-1 adjustment --- tests/phpunit/tests/html-api/wpHtmlTagProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index cec84d8f7224d..8a949d63e04a5 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -2789,7 +2789,7 @@ public function test_applies_updates_before_proceeding() { public function insert_after( $new_html ) { $this->set_bookmark( 'here' ); $this->lexical_updates[] = new WP_HTML_Text_Replacement( - $this->bookmarks['here']->start + $this->bookmarks['here']->length + 1, + $this->bookmarks['here']->start + $this->bookmarks['here']->length, 0, $new_html ); From 282ea64e2c18d1f17bacd87128ee2de84fd3939b Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 24 May 2024 18:34:17 +0200 Subject: [PATCH 04/15] Remove off-by-1 adjustment --- src/wp-includes/html-api/class-wp-html-tag-processor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php index b79b1f6d1bac8..348ab850e69fd 100644 --- a/src/wp-includes/html-api/class-wp-html-tag-processor.php +++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php @@ -1013,7 +1013,7 @@ private function base_class_next_token() { */ $this->token_starts_at = $was_at; $this->token_length = $this->bytes_already_parsed - $this->token_starts_at; - $this->text_starts_at = $tag_ends_at + 1; + $this->text_starts_at = $tag_ends_at; $this->text_length = $this->tag_name_starts_at - $this->text_starts_at; $this->tag_name_starts_at = $tag_name_starts_at; $this->tag_name_length = $tag_name_length; From 8babb567fffd93cfd872dbdeda54252766619c17 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 24 May 2024 18:35:50 +0200 Subject: [PATCH 05/15] Fix off-by-1 --- src/wp-includes/html-api/class-wp-html-tag-processor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php index 348ab850e69fd..26d22c072e48e 100644 --- a/src/wp-includes/html-api/class-wp-html-tag-processor.php +++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php @@ -2687,7 +2687,7 @@ public function has_self_closing_flag() { *
* ^ this appears one character before the end of the closing ">". */ - return '/' === $this->html[ $this->token_starts_at + $this->token_length - 1 ]; + return '/' === $this->html[ $this->token_starts_at + $this->token_length - 2 ]; } /** From c250e032f8d61203242340948b896fd38ff677ea Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 24 May 2024 19:17:12 +0200 Subject: [PATCH 06/15] Fix interactivity --- .../class-wp-interactivity-api-directives-processor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php b/src/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php index 3b2dcb1237971..b12dcb4b3b158 100644 --- a/src/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php +++ b/src/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php @@ -107,7 +107,7 @@ public function append_content_after_template_tag_closer( string $new_content ): $bookmark = 'append_content_after_template_tag_closer'; $this->set_bookmark( $bookmark ); - $after_closing_tag = $this->bookmarks[ $bookmark ]->start + $this->bookmarks[ $bookmark ]->length + 1; + $after_closing_tag = $this->bookmarks[ $bookmark ]->start + $this->bookmarks[ $bookmark ]->length; $this->release_bookmark( $bookmark ); // Appends the new content. @@ -140,7 +140,7 @@ private function get_after_opener_tag_and_before_closer_tag_positions( bool $rew } list( $opener_tag, $closer_tag ) = $bookmarks; - $after_opener_tag = $this->bookmarks[ $opener_tag ]->start + $this->bookmarks[ $opener_tag ]->length + 1; + $after_opener_tag = $this->bookmarks[ $opener_tag ]->start + $this->bookmarks[ $opener_tag ]->length; $before_closer_tag = $this->bookmarks[ $closer_tag ]->start; if ( $rewind ) { From 19e9978378db49c7f3dd4e471f54cbe4ec391cdf Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 24 May 2024 19:38:08 +0200 Subject: [PATCH 07/15] Reflection access --- tests/phpunit/tests/html-api/wpHtmlTagProcessor.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index 8a949d63e04a5..f6a8b92e7f35d 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -493,10 +493,12 @@ public function test_tag_start_length( string $html, int $start, int $length ) { $processor->next_tag( array( 'class_name' => 'target' ) ); $start_property = new ReflectionProperty( $processor, 'token_starts_at' ); - $tag_start = $start_property->getValue( $processor ); + $start_property->setAccessible( true ); + $tag_start = $start_property->getValue( $processor ); $length_property = new ReflectionProperty( $processor, 'token_length' ); - $tag_length = $length_property->getValue( $processor ); + $length_property->setAccessible( true ); + $tag_length = $length_property->getValue( $processor ); $this->assertSame( $start, $tag_start, "Incorrect tag start position found: {$tag_start}." ); $this->assertSame( $length, $tag_length, "Incorrect tag length found: {$tag_length}." ); From 5a7f0775f4e595d93d8b36d972cf0a42845f6ccc Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Mon, 27 May 2024 20:09:44 +0200 Subject: [PATCH 08/15] Set ticket number --- tests/phpunit/tests/html-api/wpHtmlTagProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index f6a8b92e7f35d..be39c90f2c083 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -479,7 +479,7 @@ public function test_get_updated_html_applies_updates_to_content_after_seeking_t /** * Ensures that tags start and length are correctly determined. * - * @ticket 321 + * @ticket 61301 * * @dataProvider data_tag_start_length * From 85abac9a81bb07df05babb1a430e740b6d3ed820 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Mon, 27 May 2024 20:35:34 +0200 Subject: [PATCH 09/15] rework tests, add more cases --- .../tests/html-api/wpHtmlTagProcessor.php | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index be39c90f2c083..77d6005d2c19c 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -484,40 +484,53 @@ public function test_get_updated_html_applies_updates_to_content_after_seeking_t * @dataProvider data_tag_start_length * * @param string $html - * @param int $start - * @param int $length + * @param string $match_class + * @param string $expected_match */ - public function test_tag_start_length( string $html, int $start, int $length ) { - $processor = new WP_HTML_Tag_Processor( $html ); + public function test_tag_start_length( string $html, int $match_nth_token, string $expected_match ) { + $processor = new class( $html ) extends WP_HTML_Tag_Processor { + public function get_token_string() { + $this->set_bookmark( 'mark' ); + $mark = $this->bookmarks['mark']; - $processor->next_tag( array( 'class_name' => 'target' ) ); + return substr( $this->html, $mark->start, $mark->length ); + } + }; - $start_property = new ReflectionProperty( $processor, 'token_starts_at' ); - $start_property->setAccessible( true ); - $tag_start = $start_property->getValue( $processor ); + for ( $i = 0; $i < $match_nth_token; $i++ ) { + $processor->next_token(); } - $length_property = new ReflectionProperty( $processor, 'token_length' ); - $length_property->setAccessible( true ); - $tag_length = $length_property->getValue( $processor ); + $found = $processor->get_token_string(); - $this->assertSame( $start, $tag_start, "Incorrect tag start position found: {$tag_start}." ); - $this->assertSame( $length, $tag_length, "Incorrect tag length found: {$tag_length}." ); + $this->assertSame( $expected_match, $found, "Incorrect token found: {$found}." ); } /** * Data provider. * - * @return array + * @return array> */ public static function data_tag_start_length() { return array( - 'Simple DIV' => array( '
', 0, 20 ), - 'DIV with attributes' => array( '
', 0, 29 ), - 'Nested DIV' => array( '
', 5, 20 ), - 'DIV after text' => array( 'Initial
', 8, 20 ), - 'DIV after comment' => array( '
', 17, 20 ), - 'DIV before text' => array( '
Trailing', 0, 20 ), - 'DIV before comment' => array( '
', 0, 20 ), + // Tags + 'DIV start tag' => array( '
', 1, '
' ), + 'DIV start tag with attributes' => array( '
', 1, '
' ), + 'DIV end tag' => array( '
', 1, '
' ), + 'DIV end tag with attributes' => array( '
', 1, '
' ), + 'Nested DIV' => array( '
', 2, '
' ), + 'Sibling DIV' => array( '
', 3, '
' ), + 'DIV after text' => array( 'text
', 2, '
' ), + 'DIV before text' => array( '
text', 1, '
' ), + 'DIV after comment' => array( '
', 2, '
' ), + 'DIV before comment' => array( '
', 1, '
' ), + + // Text + 'Text' => array( 'Just text', 1, 'Just text' ), + 'Text in DIV' => array( '
Text
', 2, 'Text' ), + 'Text after DIV' => array( 'Text
', 1, 'Text' ), + 'Text before DIV' => array( '
Text', 2, 'Text' ), + 'Text after comment' => array( 'Text', 2, 'Text' ), + 'Text before comment' => array( 'Text ', 1, 'Text' ), ); } From fb83e4f9e2627f14dee5400d8d7309449994c1fd Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Mon, 27 May 2024 21:29:46 +0200 Subject: [PATCH 10/15] More tests --- .../tests/html-api/wpHtmlTagProcessor.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index 77d6005d2c19c..2ac9fedc515ff 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -523,14 +523,28 @@ public static function data_tag_start_length() { 'DIV before text' => array( '
text', 1, '
' ), 'DIV after comment' => array( '
', 2, '
' ), 'DIV before comment' => array( '
', 1, '
' ), + 'Start "self-closing" tag' => array( '
', 1, '
' ), // Text 'Text' => array( 'Just text', 1, 'Just text' ), 'Text in DIV' => array( '
Text
', 2, 'Text' ), - 'Text after DIV' => array( 'Text
', 1, 'Text' ), - 'Text before DIV' => array( '
Text', 2, 'Text' ), + 'Text before DIV' => array( 'Text
', 1, 'Text' ), + 'Text after DIV' => array( '
Text', 3, 'Text' ), 'Text after comment' => array( 'Text', 2, 'Text' ), 'Text before comment' => array( 'Text ', 1, 'Text' ), + + // Comments + 'Comment' => array( '', 1, '' ), + 'Comment in DIV' => array( '
', 2, '' ), + 'Comment before DIV' => array( '
', 1, '' ), + 'Comment after DIV' => array( '
', 3, '' ), + 'Comment after comment' => array( '', 2, '' ), + 'Comment before comment' => array( ' ', 1, '' ), + 'Abruptly closed comment' => array( '', 1, '' ), + 'Empty comment' => array( '', 1, '' ), + 'Funky comment' => array( '', 1, '' ), + 'PI comment' => array( '', 1, '' ), + 'CDATA comment' => array( '', 1, '' ), ); } From 3683a796fc68d0939b83371ebf6d600d45685cc3 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Mon, 27 May 2024 21:35:35 +0200 Subject: [PATCH 11/15] Fix up test names and docs --- .../tests/html-api/wpHtmlTagProcessor.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index 2ac9fedc515ff..59f5ff60361ed 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -477,17 +477,17 @@ public function test_get_updated_html_applies_updates_to_content_after_seeking_t } /** - * Ensures that tags start and length are correctly determined. + * Ensures that bookmarks start and langth correctly describe a given token in HTML. * * @ticket 61301 * - * @dataProvider data_tag_start_length + * @dataProvider data_html_nth_token_substring * - * @param string $html - * @param string $match_class - * @param string $expected_match + * @param string $html Input HTML. + * @param string $match_nth_token The number of times to call ::match_token. + * @param string $expected_match The expected HTML at the matched token. */ - public function test_tag_start_length( string $html, int $match_nth_token, string $expected_match ) { + public function test_token_bookmark_span( string $html, int $match_nth_token, string $expected_match ) { $processor = new class( $html ) extends WP_HTML_Tag_Processor { public function get_token_string() { $this->set_bookmark( 'mark' ); @@ -508,9 +508,9 @@ public function get_token_string() { /** * Data provider. * - * @return array> + * @return array */ - public static function data_tag_start_length() { + public static function data_html_nth_token_substring() { return array( // Tags 'DIV start tag' => array( '
', 1, '
' ), From 995c8f722ca2f6e9b7715bcf1f6011421dae1bad Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Mon, 27 May 2024 16:21:15 -0700 Subject: [PATCH 12/15] Update tests --- .../tests/html-api/wpHtmlTagProcessor.php | 48 ++++++++++++++----- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index 59f5ff60361ed..90a2aecaf7b86 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -477,19 +477,34 @@ public function test_get_updated_html_applies_updates_to_content_after_seeking_t } /** - * Ensures that bookmarks start and langth correctly describe a given token in HTML. + * Ensures that bookmarks start and length correctly describe a given token in HTML. * * @ticket 61301 * * @dataProvider data_html_nth_token_substring * * @param string $html Input HTML. - * @param string $match_nth_token The number of times to call ::match_token. - * @param string $expected_match The expected HTML at the matched token. + * @param int $match_nth_token Which token to inspect from input HTML. + * @param string $expected_match Expected full raw token bookmark should capture. */ public function test_token_bookmark_span( string $html, int $match_nth_token, string $expected_match ) { $processor = new class( $html ) extends WP_HTML_Tag_Processor { - public function get_token_string() { + /** + * Returns the raw span of HTML for the currently-matched + * token, or null if not paused on any token. + * + * @return string|null Raw HTML content of currently-matched token, + * otherwise `null` if not matched. + */ + public function get_raw_token() { + if ( + WP_HTML_Tag_Processor::STATE_READY === $this->parser_state || + WP_HTML_Tag_Processor::STATE_INCOMPLETE_INPUT === $this->parser_state || + WP_HTML_Tag_Processor::STATE_COMPLETE === $this->parser_state + ) { + return null; + } + $this->set_bookmark( 'mark' ); $mark = $this->bookmarks['mark']; @@ -498,11 +513,20 @@ public function get_token_string() { }; for ( $i = 0; $i < $match_nth_token; $i++ ) { - $processor->next_token(); } + $processor->next_token(); + } - $found = $processor->get_token_string(); + $raw_token = $processor->get_raw_token(); + $this->assertIsString( + $raw_token, + "Failed to find raw token at position {$match_nth_token}: check test data provider." + ); - $this->assertSame( $expected_match, $found, "Incorrect token found: {$found}." ); + $this->assertSame( + $expected_match, + $raw_token, + 'Bookmarked wrong span of text for full matched token.' + ); } /** @@ -512,7 +536,7 @@ public function get_token_string() { */ public static function data_html_nth_token_substring() { return array( - // Tags + // Tags. 'DIV start tag' => array( '
', 1, '
' ), 'DIV start tag with attributes' => array( '
', 1, '
' ), 'DIV end tag' => array( '
', 1, '
' ), @@ -525,7 +549,7 @@ public static function data_html_nth_token_substring() { 'DIV before comment' => array( '
', 1, '
' ), 'Start "self-closing" tag' => array( '
', 1, '
' ), - // Text + // Text. 'Text' => array( 'Just text', 1, 'Just text' ), 'Text in DIV' => array( '
Text
', 2, 'Text' ), 'Text before DIV' => array( 'Text
', 1, 'Text' ), @@ -533,7 +557,7 @@ public static function data_html_nth_token_substring() { 'Text after comment' => array( 'Text', 2, 'Text' ), 'Text before comment' => array( 'Text ', 1, 'Text' ), - // Comments + // Comments. 'Comment' => array( '', 1, '' ), 'Comment in DIV' => array( '
', 2, '' ), 'Comment before DIV' => array( '
', 1, '' ), @@ -543,8 +567,8 @@ public static function data_html_nth_token_substring() { 'Abruptly closed comment' => array( '', 1, '' ), 'Empty comment' => array( '', 1, '' ), 'Funky comment' => array( '', 1, '' ), - 'PI comment' => array( '', 1, '' ), - 'CDATA comment' => array( '', 1, '' ), + 'PI lookalike comment' => array( '', 1, '' ), + 'CDATA lookalike comment' => array( '', 1, '' ), ); } From 8d14cb7f631e380de0926d06d59bb6fbb8de35eb Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Mon, 27 May 2024 16:41:27 -0700 Subject: [PATCH 13/15] Add void tag test case --- tests/phpunit/tests/html-api/wpHtmlTagProcessor.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index 90a2aecaf7b86..2ce06301fe5b9 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -548,6 +548,9 @@ public static function data_html_nth_token_substring() { 'DIV after comment' => array( '
', 2, '
' ), 'DIV before comment' => array( '
', 1, '
' ), 'Start "self-closing" tag' => array( '
', 1, '
' ), + 'Void tag' => array( '', 1, '' ), + 'Void tag w/self-closing flag' => array( '', 1, '' ), + 'Void tag inside DIV' => array( '
', 2, '' ), // Text. 'Text' => array( 'Just text', 1, 'Just text' ), From 12a59c85a7bdf53b085c396331e723f2d6264c57 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Mon, 27 May 2024 16:43:10 -0700 Subject: [PATCH 14/15] Add SCRIPT test case --- tests/phpunit/tests/html-api/wpHtmlTagProcessor.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index 2ce06301fe5b9..af162188fe532 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -552,6 +552,10 @@ public static function data_html_nth_token_substring() { 'Void tag w/self-closing flag' => array( '', 1, '' ), 'Void tag inside DIV' => array( '
', 2, '' ), + // Special atomic tags. + 'SCRIPT tag' => array( '', 1, '' ), + 'SCRIPT double-escape' => array( '
', 1, '' ), + // Text. 'Text' => array( 'Just text', 1, 'Just text' ), 'Text in DIV' => array( '
Text
', 2, 'Text' ), From f8a9907b63891f15ede539e865dc54ea76c88e25 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Mon, 27 May 2024 16:51:38 -0700 Subject: [PATCH 15/15] Fix new tests. --- tests/phpunit/tests/html-api/wpHtmlTagProcessor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index af162188fe532..fad1000dd763c 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -548,9 +548,9 @@ public static function data_html_nth_token_substring() { 'DIV after comment' => array( '
', 2, '
' ), 'DIV before comment' => array( '
', 1, '
' ), 'Start "self-closing" tag' => array( '
', 1, '
' ), - 'Void tag' => array( '', 1, '' ), - 'Void tag w/self-closing flag' => array( '', 1, '' ), - 'Void tag inside DIV' => array( '
', 2, '' ), + 'Void tag' => array( '', 1, '' ), + 'Void tag w/self-closing flag' => array( '', 1, '' ), + 'Void tag inside DIV' => array( '
', 2, '' ), // Special atomic tags. 'SCRIPT tag' => array( '', 1, '' ),