Skip to content

Commit

Permalink
HTML API: Support PARAM, SOURCE, and TRACK tags.
Browse files Browse the repository at this point in the history
Adds support for the following HTML elements to the HTML Processor:

 - PARAM, SOURCE, TRACK

Previously these elements were not supported and the HTML Processor would bail when encountering them. Now, with this patch applied, it will proceed to parse an HTML document when encountering those tags.

Props jonsurrell, dmsnell
Fixes #60283



git-svn-id: https://develop.svn.wordpress.org/trunk@57326 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
dmsnell committed Jan 23, 2024
1 parent a1cf525 commit 6653002
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
16 changes: 11 additions & 5 deletions src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
* - Heading elements: H1, H2, H3, H4, H5, H6, HGROUP.
* - Links: A.
* - Lists: DD, DL, DT, LI, OL, LI.
* - Media elements: AUDIO, CANVAS, EMBED, FIGCAPTION, FIGURE, IMG, MAP, PICTURE, VIDEO.
* - Media elements: AUDIO, CANVAS, EMBED, FIGCAPTION, FIGURE, IMG, MAP, PARAM, PICTURE, SOURCE, VIDEO, TRACK.
* - Paragraph: BR, P.
* - Phrasing elements: AREA, ABBR, BDI, BDO, CITE, DATA, DEL, DFN, INS, MARK, OUTPUT, Q, SAMP, SUB, SUP, TIME, VAR.
* - Sectioning elements: ARTICLE, ASIDE, HR, NAV, SECTION.
Expand Down Expand Up @@ -982,6 +982,15 @@ private function step_in_body() {
$this->insert_html_element( $this->state->current_token );
$this->state->frameset_ok = false;
return true;

/*
* > A start tag whose tag name is one of: "param", "source", "track"
*/
case '+PARAM':
case '+SOURCE':
case '+TRACK':
$this->insert_html_element( $this->state->current_token );
return true;
}

/*
Expand Down Expand Up @@ -1027,7 +1036,6 @@ private function step_in_body() {
case 'OBJECT':
case 'OPTGROUP':
case 'OPTION':
case 'PARAM':
case 'PLAINTEXT':
case 'RB':
case 'RP':
Expand All @@ -1036,7 +1044,6 @@ private function step_in_body() {
case 'SARCASM':
case 'SCRIPT':
case 'SELECT':
case 'SOURCE':
case 'STYLE':
case 'SVG':
case 'TABLE':
Expand All @@ -1049,7 +1056,6 @@ private function step_in_body() {
case 'THEAD':
case 'TITLE':
case 'TR':
case 'TRACK':
case 'XMP':
$this->last_error = self::ERROR_UNSUPPORTED;
throw new WP_HTML_Unsupported_Exception( "Cannot process {$tag_name} element." );
Expand Down Expand Up @@ -1712,8 +1718,8 @@ public static function is_void( $tag_name ) {
'HR' === $tag_name ||
'IMG' === $tag_name ||
'INPUT' === $tag_name ||
'LINK' === $tag_name ||
'KEYGEN' === $tag_name || // Obsolete but still treated as void.
'LINK' === $tag_name ||
'META' === $tag_name ||
'PARAM' === $tag_name || // Obsolete but still treated as void.
'SOURCE' === $tag_name ||
Expand Down
4 changes: 1 addition & 3 deletions tests/phpunit/tests/html-api/wpHtmlProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public function data_void_tags() {
'KEYGEN' => array( 'KEYGEN' ),
'LINK' => array( 'LINK' ),
'META' => array( 'META' ),
'PARAM' => array( 'PARAM' ),
'SOURCE' => array( 'SOURCE' ),
'TRACK' => array( 'TRACK' ),
'WBR' => array( 'WBR' ),
Expand Down Expand Up @@ -264,7 +265,6 @@ public function data_unsupported_special_in_body_tags() {
'OBJECT' => array( 'OBJECT' ),
'OPTGROUP' => array( 'OPTGROUP' ),
'OPTION' => array( 'OPTION' ),
'PARAM' => array( 'PARAM' ),
'PLAINTEXT' => array( 'PLAINTEXT' ),
'RB' => array( 'RB' ),
'RP' => array( 'RP' ),
Expand All @@ -273,7 +273,6 @@ public function data_unsupported_special_in_body_tags() {
'SARCASM' => array( 'SARCASM' ),
'SCRIPT' => array( 'SCRIPT' ),
'SELECT' => array( 'SELECT' ),
'SOURCE' => array( 'SOURCE' ),
'STYLE' => array( 'STYLE' ),
'SVG' => array( 'SVG' ),
'TABLE' => array( 'TABLE' ),
Expand All @@ -286,7 +285,6 @@ public function data_unsupported_special_in_body_tags() {
'THEAD' => array( 'THEAD' ),
'TITLE' => array( 'TITLE' ),
'TR' => array( 'TR' ),
'TRACK' => array( 'TRACK' ),
'XMP' => array( 'XMP' ),
);
}
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ public function data_unsupported_elements() {
'RTC', // Neutralized.
'SCRIPT',
'SELECT',
'SOURCE',
'STYLE',
'SVG',
'TABLE',
Expand All @@ -212,7 +211,6 @@ public function data_unsupported_elements() {
'THEAD',
'TITLE',
'TR',
'TRACK',
'XMP', // Deprecated, use PRE instead.
);

Expand Down

0 comments on commit 6653002

Please sign in to comment.