Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down Expand Up @@ -977,7 +988,6 @@ private function step_in_body() {
case 'FRAME':
case 'FRAMESET':
case 'HEAD':
case 'HR':
case 'HTML':
case 'IFRAME':
case 'INPUT':
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/tests/html-api/wpHtmlProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ public function data_unsupported_elements() {
'FRAME',
'FRAMESET',
'HEAD',
'HR',
'HTML',
'IFRAME',
'INPUT',
Expand Down
16 changes: 16 additions & 0 deletions tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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( '<p><hr>' );

$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.
*
Expand Down