From 409ff38b730653791093665cc792c7650509fcec Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Mon, 18 Dec 2023 14:22:26 -0600 Subject: [PATCH] Update more tests, more checks, add SARCASM --- .../html-api/class-wp-html-processor.php | 3 +- .../tests/html-api/wpHtmlProcessor.php | 1 + .../html-api/wpHtmlProcessorBreadcrumbs.php | 70 +++++++------- .../wpHtmlSupportRequiredOpenElements.php | 91 +++++-------------- 4 files changed, 58 insertions(+), 107 deletions(-) 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 bf14d03d105c8..603bd9232944f 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -879,8 +879,6 @@ private function step_in_body() { * @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inbody */ switch ( $tag_name ) { - case 'ABBR': - case 'ACRONYM': case 'APPLET': case 'AREA': case 'BASE': @@ -924,6 +922,7 @@ private function step_in_body() { case 'RP': case 'RT': case 'RTC': + case 'SARCASM': case 'SCRIPT': case 'SELECT': case 'SOURCE': diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessor.php b/tests/phpunit/tests/html-api/wpHtmlProcessor.php index 622d52ac47871..2dbd76b802959 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessor.php @@ -199,6 +199,7 @@ public function data_unsupported_special_in_body_tags() { array( 'RP' ), array( 'RT' ), array( 'RTC' ), + array( 'SARCASM' ), array( 'SCRIPT' ), array( 'SELECT' ), array( 'SOURCE' ), diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php b/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php index e758bf72cd2f5..9a9936a599118 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php @@ -37,14 +37,26 @@ public function test_navigates_into_normative_html_for_supported_elements( $html public function data_single_tag_of_supported_elements() { $supported_elements = array( 'A', + 'ABBR', + 'ACRONYM', // Neutralized 'ADDRESS', 'ARTICLE', 'ASIDE', + 'AUDIO', 'B', + 'BDI', + 'BDO', 'BIG', + 'BLINK', // Deprecated 'BUTTON', + 'CANVAS', 'CENTER', // Neutralized + 'CITE', 'CODE', + 'DATA', + 'DATALIST', + 'DEFN', + 'DEL', 'DETAILS', 'DIALOG', 'DIR', @@ -66,19 +78,42 @@ public function data_single_tag_of_supported_elements() { 'HGROUP', 'I', 'IMG', + 'INS', + 'ISINDEX', // Deprecated + 'KBD', + 'LABEL', + 'LEGEND', 'MAIN', + 'MAP', + 'MARK', 'MENU', + 'METER', + 'MULTICOL', // Deprecated 'NAV', + 'NEXTID',// Deprecated + 'OUTPUT', 'P', + 'PICTURE', + 'PROGRESS', + 'Q', + 'RUBY', + 'SAMP', 'SEARCH', 'SECTION', + 'SLOT', 'SMALL', + 'SPACER', // Deprecated 'SPAN', 'STRIKE', 'STRONG', + 'SUB', 'SUMMARY', + 'SUP', + 'TIME', 'TT', 'U', + 'VAR', + 'VIDEO', ); $data = array(); @@ -121,28 +156,16 @@ public function test_fails_when_encountering_unsupported_tag( $html ) { */ public function data_unsupported_elements() { $unsupported_elements = array( - 'ABBR', - 'ACRONYM', // Neutralized 'APPLET', // Deprecated 'AREA', - 'AUDIO', 'BASE', - 'BDI', - 'BDO', 'BGSOUND', // Deprecated; self-closing if self-closing flag provided, otherwise normal. - 'BLINK', // Deprecated 'BODY', 'BR', - 'CANVAS', 'CAPTION', - 'CITE', 'COL', 'COLGROUP', - 'DATA', - 'DATALIST', 'DD', - 'DEL', - 'DEFN', 'DT', 'EMBED', 'FORM', @@ -153,23 +176,13 @@ public function data_unsupported_elements() { 'HTML', 'IFRAME', 'INPUT', - 'INS', - 'ISINDEX', // Deprecated - 'KBD', 'KEYGEN', // Deprecated; void - 'LABEL', - 'LEGEND', 'LI', 'LINK', 'LISTING', // Deprecated, use PRE instead. - 'MAP', - 'MARK', 'MARQUEE', // Deprecated 'MATH', 'META', - 'METER', - 'MULTICOL', // Deprecated - 'NEXTID', // Deprecated 'NOBR', // Neutralized 'NOEMBED', // Neutralized 'NOFRAMES', // Neutralized @@ -178,26 +191,16 @@ public function data_unsupported_elements() { 'OL', 'OPTGROUP', 'OPTION', - 'OUTPUT', - 'PICTURE', 'PLAINTEXT', // Neutralized 'PRE', - 'PROGRESS', - 'Q', 'RB', // Neutralized 'RP', 'RT', 'RTC', // Neutralized - 'RUBY', - 'SAMP', 'SCRIPT', 'SELECT', - 'SLOT', 'SOURCE', - 'SPACER', // Deprecated 'STYLE', - 'SUB', - 'SUP', 'SVG', 'TABLE', 'TBODY', @@ -207,13 +210,10 @@ public function data_unsupported_elements() { 'TFOOT', 'TH', 'THEAD', - 'TIME', 'TITLE', 'TR', 'TRACK', 'UL', - 'VAR', - 'VIDEO', 'WBR', 'XMP', // Deprecated, use PRE instead. ); diff --git a/tests/phpunit/tests/html-api/wpHtmlSupportRequiredOpenElements.php b/tests/phpunit/tests/html-api/wpHtmlSupportRequiredOpenElements.php index 9dbb689df0329..a66a8a689ced1 100644 --- a/tests/phpunit/tests/html-api/wpHtmlSupportRequiredOpenElements.php +++ b/tests/phpunit/tests/html-api/wpHtmlSupportRequiredOpenElements.php @@ -72,21 +72,14 @@ public function test_has_element_in_scope_needs_support() { $this->ensure_support_is_added_everywhere( 'OBJECT' ); $this->ensure_support_is_added_everywhere( 'TEMPLATE' ); - // MathML Elements - $this->ensure_support_is_added_everywhere( 'MI' ); - $this->ensure_support_is_added_everywhere( 'MO' ); - $this->ensure_support_is_added_everywhere( 'MN' ); - $this->ensure_support_is_added_everywhere( 'MS' ); - $this->ensure_support_is_added_everywhere( 'MTEXT' ); - $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' ); + // MathML Elements. + $this->ensure_support_is_added_everywhere( 'MATH' ); /* * SVG elements: note that TITLE is both an HTML element and an SVG element * so care must be taken when adding support for either one. */ - $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' ); - $this->ensure_support_is_added_everywhere( 'DESC' ); - $this->ensure_support_is_added_everywhere( 'TITLE' ); + $this->ensure_support_is_added_everywhere( 'SVG' ); } /** @@ -115,21 +108,14 @@ public function test_has_element_in_list_item_scope_needs_support() { $this->ensure_support_is_added_everywhere( 'OBJECT' ); $this->ensure_support_is_added_everywhere( 'TEMPLATE' ); - // MathML Elements - $this->ensure_support_is_added_everywhere( 'MI' ); - $this->ensure_support_is_added_everywhere( 'MO' ); - $this->ensure_support_is_added_everywhere( 'MN' ); - $this->ensure_support_is_added_everywhere( 'MS' ); - $this->ensure_support_is_added_everywhere( 'MTEXT' ); - $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' ); + // MathML Elements. + $this->ensure_support_is_added_everywhere( 'MATH' ); /* * SVG elements: note that TITLE is both an HTML element and an SVG element * so care must be taken when adding support for either one. */ - $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' ); - $this->ensure_support_is_added_everywhere( 'DESC' ); - $this->ensure_support_is_added_everywhere( 'TITLE' ); + $this->ensure_support_is_added_everywhere( 'SVG' ); // These elements are specific to list item scope. $this->ensure_support_is_added_everywhere( 'OL' ); @@ -161,21 +147,14 @@ public function test_has_element_in_button_scope_needs_support() { $this->ensure_support_is_added_everywhere( 'OBJECT' ); $this->ensure_support_is_added_everywhere( 'TEMPLATE' ); - // MathML Elements - $this->ensure_support_is_added_everywhere( 'MI' ); - $this->ensure_support_is_added_everywhere( 'MO' ); - $this->ensure_support_is_added_everywhere( 'MN' ); - $this->ensure_support_is_added_everywhere( 'MS' ); - $this->ensure_support_is_added_everywhere( 'MTEXT' ); - $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' ); + // MathML Elements. + $this->ensure_support_is_added_everywhere( 'MATH' ); /* * SVG elements: note that TITLE is both an HTML element and an SVG element * so care must be taken when adding support for either one. */ - $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' ); - $this->ensure_support_is_added_everywhere( 'DESC' ); - $this->ensure_support_is_added_everywhere( 'TITLE' ); + $this->ensure_support_is_added_everywhere( 'SVG' ); } /** @@ -201,21 +180,14 @@ public function test_after_element_pop_must_maintain_p_in_button_scope_flag() { $this->ensure_support_is_added_everywhere( 'OBJECT' ); $this->ensure_support_is_added_everywhere( 'TEMPLATE' ); - // MathML Elements - $this->ensure_support_is_added_everywhere( 'MI' ); - $this->ensure_support_is_added_everywhere( 'MO' ); - $this->ensure_support_is_added_everywhere( 'MN' ); - $this->ensure_support_is_added_everywhere( 'MS' ); - $this->ensure_support_is_added_everywhere( 'MTEXT' ); - $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' ); + // MathML Elements. + $this->ensure_support_is_added_everywhere( 'MATH' ); /* * SVG elements: note that TITLE is both an HTML element and an SVG element * so care must be taken when adding support for either one. */ - $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' ); - $this->ensure_support_is_added_everywhere( 'DESC' ); - $this->ensure_support_is_added_everywhere( 'TITLE' ); + $this->ensure_support_is_added_everywhere( 'SVG' ); } /** @@ -241,21 +213,14 @@ public function test_after_element_push_must_maintain_p_in_button_scope_flag() { $this->ensure_support_is_added_everywhere( 'OBJECT' ); $this->ensure_support_is_added_everywhere( 'TEMPLATE' ); - // MathML Elements - $this->ensure_support_is_added_everywhere( 'MI' ); - $this->ensure_support_is_added_everywhere( 'MO' ); - $this->ensure_support_is_added_everywhere( 'MN' ); - $this->ensure_support_is_added_everywhere( 'MS' ); - $this->ensure_support_is_added_everywhere( 'MTEXT' ); - $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' ); + // MathML Elements. + $this->ensure_support_is_added_everywhere( 'MATH' ); /* * SVG elements: note that TITLE is both an HTML element and an SVG element * so care must be taken when adding support for either one. */ - $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' ); - $this->ensure_support_is_added_everywhere( 'DESC' ); - $this->ensure_support_is_added_everywhere( 'TITLE' ); + $this->ensure_support_is_added_everywhere( 'SVG' ); } /** @@ -280,21 +245,14 @@ public function test_has_element_in_table_scope_needs_support() { $this->ensure_support_is_added_everywhere( 'OBJECT' ); $this->ensure_support_is_added_everywhere( 'TEMPLATE' ); - // MathML Elements - $this->ensure_support_is_added_everywhere( 'MI' ); - $this->ensure_support_is_added_everywhere( 'MO' ); - $this->ensure_support_is_added_everywhere( 'MN' ); - $this->ensure_support_is_added_everywhere( 'MS' ); - $this->ensure_support_is_added_everywhere( 'MTEXT' ); - $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' ); + // MathML Elements. + $this->ensure_support_is_added_everywhere( 'MATH' ); /* * SVG elements: note that TITLE is both an HTML element and an SVG element * so care must be taken when adding support for either one. */ - $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' ); - $this->ensure_support_is_added_everywhere( 'DESC' ); - $this->ensure_support_is_added_everywhere( 'TITLE' ); + $this->ensure_support_is_added_everywhere( 'SVG' ); // These elements are specific to TABLE scope. $this->ensure_support_is_added_everywhere( 'HTML' ); @@ -335,21 +293,14 @@ public function test_has_element_in_select_scope_needs_support() { $this->ensure_support_is_added_everywhere( 'OBJECT' ); $this->ensure_support_is_added_everywhere( 'TEMPLATE' ); - // MathML Elements - $this->ensure_support_is_added_everywhere( 'MI' ); - $this->ensure_support_is_added_everywhere( 'MO' ); - $this->ensure_support_is_added_everywhere( 'MN' ); - $this->ensure_support_is_added_everywhere( 'MS' ); - $this->ensure_support_is_added_everywhere( 'MTEXT' ); - $this->ensure_support_is_added_everywhere( 'ANNOTATION-XML' ); + // MathML Elements. + $this->ensure_support_is_added_everywhere( 'MATH' ); /* * SVG elements: note that TITLE is both an HTML element and an SVG element * so care must be taken when adding support for either one. */ - $this->ensure_support_is_added_everywhere( 'FOREIGNOBJECT' ); - $this->ensure_support_is_added_everywhere( 'DESC' ); - $this->ensure_support_is_added_everywhere( 'TITLE' ); + $this->ensure_support_is_added_everywhere( 'SVG' ); // These elements are specific to SELECT scope. $this->ensure_support_is_added_everywhere( 'OPTGROUP' );