From e8b5d1a702e9fbf6a1f225df6501ea2e517938ec Mon Sep 17 00:00:00 2001 From: gziolo Date: Mon, 9 Dec 2024 12:44:17 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@59500 git-svn-id: http://core.svn.wordpress.org/trunk@58886 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../html-api/class-wp-html-processor.php | 27 ++++++++++++++++--- wp-includes/version.php | 2 +- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/wp-includes/html-api/class-wp-html-processor.php b/wp-includes/html-api/class-wp-html-processor.php index e88757ec7b..7b156d8a60 100644 --- a/wp-includes/html-api/class-wp-html-processor.php +++ b/wp-includes/html-api/class-wp-html-processor.php @@ -2318,7 +2318,14 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor { */ $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" @@ -4391,7 +4398,14 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor { } $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(); } /* @@ -4586,7 +4600,14 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor { */ 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" diff --git a/wp-includes/version.php b/wp-includes/version.php index b6e7a1f23a..8b16c0a3c7 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59499'; +$wp_version = '6.8-alpha-59500'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.