Skip to content

Commit

Permalink
Complete cases in step_in_table
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Jul 4, 2024
1 parent 945fab5 commit e0787ef
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1652,20 +1652,36 @@ private function step_in_select() {
* @return bool Whether an element was found.
*/
private function step_in_table() {
$tag_name = $this->get_tag();
$op_sigil = $this->is_tag_closer() ? '-' : '+';
$op = "{$op_sigil}{$tag_name}";
$token_name = $this->get_token_name();
$token_type = $this->get_token_type();
$op_sigil = '#tag' === $token_type ? ( parent::is_tag_closer() ? '-' : '+' ) : '';
$op = "{$op_sigil}{$token_name}";

Check failure on line 1659 in src/wp-includes/html-api/class-wp-html-processor.php

View workflow job for this annotation

GitHub Actions / PHP coding standards / Run coding standards checks

Functions must not contain multiple empty lines in a row; found 2 empty lines

switch ( $op ) {
/*
* > A character token, if the current node is table, tbody, template, tfoot, thead, or tr element
*/
case '#text':
$this->last_error = self::ERROR_UNSUPPORTED;
throw new WP_HTML_Unsupported_Exception( "Text in tables is not supported." );

Check failure on line 1667 in src/wp-includes/html-api/class-wp-html-processor.php

View workflow job for this annotation

GitHub Actions / PHP coding standards / Run coding standards checks

String "Text in tables is not supported." does not require double quotes; use single quotes instead

/*
* > A comment token
*/
case '#comment':
case '#funky-comment':
$this->insert_html_element( $this->state->current_token );
return true;

Check failure on line 1676 in src/wp-includes/html-api/class-wp-html-processor.php

View workflow job for this annotation

GitHub Actions / PHP coding standards / Run coding standards checks

Functions must not contain multiple empty lines in a row; found 2 empty lines

/*
* > A DOCTYPE token
*/
case 'html':
// Parse error. Ignore the token.
return $this->step();

/*
* > A start tag whose tag name is "caption"
*/
Expand Down Expand Up @@ -1783,7 +1799,7 @@ private function step_in_table() {
case '+INPUT':
$type_attribute = $this->get_attribute( 'type' );
if ( ! is_string( $type_attribute ) || 'hidden' !== strtolower( $type_attribute ) ) {
goto in_table_anything_else;
break;
}
// parse error
$this->insert_html_element( $this->state->current_token );
Expand All @@ -1807,16 +1823,15 @@ private function step_in_table() {
* > An end-of-file token
*/

/*
* > Anything else
* > Parse error. Enable foster parenting, process the token using the rules for the
* > "in body" insertion mode, and then disable foster parenting.
*/
default:
in_table_anything_else:
$this->last_error = self::ERROR_UNSUPPORTED;
throw new WP_HTML_Unsupported_Exception( "Cannot process {$tag_name} element." );
}

/*
* > Anything else
* > Parse error. Enable foster parenting, process the token using the rules for the
* > "in body" insertion mode, and then disable foster parenting.
*/
$this->last_error = self::ERROR_UNSUPPORTED;
throw new WP_HTML_Unsupported_Exception( "Cannot process {$tag_name} element." );
}

/**
Expand Down

0 comments on commit e0787ef

Please sign in to comment.