Skip to content

Commit

Permalink
HTML API: Step past closing HTML, BODY tags
Browse files Browse the repository at this point in the history
The HTML specification does not close HTML or BODY tags (pop them off the stack of open elements) when their tag closers are encountered. The HTML processor correctly handled this behavior, however it incorrectly "paused" by returning true from the step functions. 

Props jonsurrell, dmsnell, gziolo.
Fixes #62583.



git-svn-id: https://develop.svn.wordpress.org/trunk@59500 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
gziolo committed Dec 9, 2024
1 parent a1079b6 commit 0d42819
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2318,7 +2318,14 @@ private function step_in_body(): bool {
*/

$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_AFTER_BODY;
return true;
/*
* The BODY element is not removed from the stack of open elements.
* Only internal state has changed, this does not qualify as a "step"
* in terms of advancing through the document to another token.
* Nothing has been pushed or popped.
* Proceed to parse the next item.
*/
return $this->step();

/*
* > An end tag whose tag name is "html"
Expand Down Expand Up @@ -4391,7 +4398,14 @@ private function step_after_body(): bool {
}

$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_AFTER_AFTER_BODY;
return true;
/*
* The HTML element is not removed from the stack of open elements.
* Only internal state has changed, this does not qualify as a "step"
* in terms of advancing through the document to another token.
* Nothing has been pushed or popped.
* Proceed to parse the next item.
*/
return $this->step();
}

/*
Expand Down Expand Up @@ -4586,7 +4600,14 @@ private function step_after_frameset(): bool {
*/
case '-HTML':
$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_AFTER_AFTER_FRAMESET;
return true;
/*
* The HTML element is not removed from the stack of open elements.
* Only internal state has changed, this does not qualify as a "step"
* in terms of advancing through the document to another token.
* Nothing has been pushed or popped.
* Proceed to parse the next item.
*/
return $this->step();

/*
* > A start tag whose tag name is "noframes"
Expand Down

0 comments on commit 0d42819

Please sign in to comment.