From e6e05ae2cfb46ff0484b7b52e10d9a72d682c10c Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 13 Sep 2024 12:45:27 +0200 Subject: [PATCH] Ensure that HTML nodes in foreign content are handled This condition: > Reprocess the token according to the rules given in the section > corresponding to the current insertion mode in HTML content. Was resulting in an infinite loop in fragment cases. In full documents, after popping nodes the context is always moved so that foreign content parsing is not used. This is not guaranteed in a fragment and could cause an infinite loop. --- src/wp-includes/html-api/class-wp-html-processor.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index 28e5c150a8635..cf4f8d7b86b49 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -4501,7 +4501,7 @@ private function step_in_foreign_content(): bool { $this->state->stack_of_open_elements->pop(); } - return $this->step( self::REPROCESS_CURRENT_NODE ); + goto in_foreign_content_process_in_current_insertion_mode; } /* @@ -4577,6 +4577,7 @@ private function step_in_foreign_content(): bool { goto in_foreign_content_end_tag_loop; } + in_foreign_content_process_in_current_insertion_mode: switch ( $this->state->insertion_mode ) { case WP_HTML_Processor_State::INSERTION_MODE_INITIAL: return $this->step_initial();