Skip to content

Commit 1637791

Browse files
committed
HTML API: Prevent infinite loop in foreign content reprocessing step.
An infinite loop was discovered in specific situations within foreign content inside the HTML Processor when a given node inside foreign content must be handled in the rules for the current insertion mode. This patch resolves the loop by handling those nodes directly instead of reprocessing the node, which previously was redirecting control flow back to where the loop started. Developed in https://github.com/wordpress/wordpress-develop/7347 Discussed in https://core.trac.wordpress.org/ticket/61656 Follow-up to [58868]. Props jonsurrell. See #61576. git-svn-id: https://develop.svn.wordpress.org/trunk@59024 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d2ce8dd commit 1637791

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/wp-includes/html-api/class-wp-html-processor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4501,7 +4501,7 @@ private function step_in_foreign_content(): bool {
45014501

45024502
$this->state->stack_of_open_elements->pop();
45034503
}
4504-
return $this->step( self::REPROCESS_CURRENT_NODE );
4504+
goto in_foreign_content_process_in_current_insertion_mode;
45054505
}
45064506

45074507
/*
@@ -4577,6 +4577,7 @@ private function step_in_foreign_content(): bool {
45774577
goto in_foreign_content_end_tag_loop;
45784578
}
45794579

4580+
in_foreign_content_process_in_current_insertion_mode:
45804581
switch ( $this->state->insertion_mode ) {
45814582
case WP_HTML_Processor_State::INSERTION_MODE_INITIAL:
45824583
return $this->step_initial();

0 commit comments

Comments
 (0)