diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index cce26a60c5350..910c1f24f1b18 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -109,7 +109,7 @@ * - Media elements: AUDIO, CANVAS, FIGCAPTION, FIGURE, IMG, MAP, PICTURE, VIDEO. * - Paragraph: P. * - Phrasing elements: ABBR, BDI, BDO, CITE, DATA, DEL, DFN, INS, MARK, OUTPUT, Q, SAMP, SUB, SUP, TIME, VAR. - * - Sectioning elements: ARTICLE, ASIDE, NAV, SECTION. + * - Sectioning elements: ARTICLE, ASIDE, HR, NAV, SECTION. * - Templating elements: SLOT. * - Text decoration: RUBY. * - Deprecated elements: ACRONYM, BLINK, CENTER, DIR, ISINDEX, MULTICOL, NEXTID, SPACER. @@ -941,6 +941,17 @@ private function step_in_body() { $this->reconstruct_active_formatting_elements(); $this->insert_html_element( $this->state->current_token ); return true; + + /* + * > A start tag whose tag name is "hr" + */ + case '+HR': + if ( $this->state->stack_of_open_elements->has_p_in_button_scope() ) { + $this->close_a_p_element(); + } + $this->insert_html_element( $this->state->current_token ); + $this->state->frameset_ok = false; + return true; } /* @@ -977,7 +988,6 @@ private function step_in_body() { case 'FRAME': case 'FRAMESET': case 'HEAD': - case 'HR': case 'HTML': case 'IFRAME': case 'INPUT': diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessor.php b/tests/phpunit/tests/html-api/wpHtmlProcessor.php index d9f1357b5c66f..d1f0767e9ce13 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessor.php @@ -173,7 +173,6 @@ public function data_unsupported_special_in_body_tags() { 'FRAME' => array( 'FRAME' ), 'FRAMESET' => array( 'FRAMESET' ), 'HEAD' => array( 'HEAD' ), - 'HR' => array( 'HR' ), 'HTML' => array( 'HTML' ), 'IFRAME' => array( 'IFRAME' ), 'INPUT' => array( 'INPUT' ), diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php b/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php index 15d38d6f70c6c..c16d38146acb3 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php @@ -175,7 +175,6 @@ public function data_unsupported_elements() { 'FRAME', 'FRAMESET', 'HEAD', - 'HR', 'HTML', 'IFRAME', 'INPUT', diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php b/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php index c1adf9a71a3f8..ba9640f2efdc7 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php @@ -224,6 +224,22 @@ public function test_in_body_button_with_button_in_scope_as_ancestor() { $this->assertSame( array( 'HTML', 'BODY', 'BUTTON' ), $p->get_breadcrumbs(), 'Failed to produce expected DOM nesting for third button.' ); } + /** + * Verifies that HR closes an open p tag + * + * @ticket 60283 + */ + public function test_in_body_hr_element_closes_open_p_tag() { + $processor = WP_HTML_Processor::create_fragment( '


' ); + + $processor->next_tag( 'HR' ); + $this->assertSame( + array( 'HTML', 'BODY', 'HR' ), + $processor->get_breadcrumbs(), + 'Expected HR to be a direct child of the BODY, having closed the open P element.' + ); + } + /** * Verifies that H1 through H6 elements close an open P element. *