Skip to content

Commit 0d42819

Browse files
committed
HTML API: Step past closing HTML, BODY tags
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
1 parent a1079b6 commit 0d42819

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,7 +2318,14 @@ private function step_in_body(): bool {
23182318
*/
23192319

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

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

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

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

45914612
/*
45924613
* > A start tag whose tag name is "noframes"

0 commit comments

Comments
 (0)