HTML API: Fix logic bug in HTML Processor when opening A element.

A mistake in the original code handling opening A elements in the HTML Processor led to mistakes in parsing where the Processor would bail in situations when it could have proceeded. While this was errant behavior, it didn't violate the public contract since it would bail in these situations.

This patch fixes the mistake, which was to only break out of the innermost loop instead of breaking from the containing loop, which resolves the issue.

Developed in https://github.com/WordPress/wordpress-develop/pull/7281
Discussed in https://core.trac.wordpress.org/ticket/61576

Follow-up to [56274].

Props jonsurrell.
See #61576.


git-svn-id: https://develop.svn.wordpress.org/trunk@58966 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dennis Snell 2024-09-02 21:52:34 +00:00
parent 59e07af497
commit 9bf044813b

View File

@ -2352,13 +2352,13 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
foreach ( $this->state->active_formatting_elements->walk_up() as $item ) {
switch ( $item->node_name ) {
case 'marker':
break;
break 2;
case 'A':
$this->run_adoption_agency_algorithm();
$this->state->active_formatting_elements->remove_node( $item );
$this->state->stack_of_open_elements->remove_node( $item );
break;
break 2;
}
}