From 4639ff8920189480d0f39f8c2275277d18f73f9b Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Fri, 12 Jan 2024 13:23:12 -0500 Subject: [PATCH] Remove early bailout of special elements. It's duplicated. --- .../html-api/class-wp-html-tag-processor.php | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php index 5fbdcc28b1b9c..8f9e7b93e5c73 100644 --- a/src/wp-includes/html-api/class-wp-html-tag-processor.php +++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php @@ -908,23 +908,6 @@ public function next_token() { } $tag_name = $this->get_tag(); - if ( - // Skips SCRIPT data. - 'SCRIPT' !== $tag_name && - - // Skips RCDATA data. - 'TEXTAREA' !== $tag_name && - 'TITLE' !== $tag_name && - - // Skips RAWTEXT data. - 'IFRAME' !== $tag_name && - 'NOEMBED' !== $tag_name && - 'NOFRAMES' !== $tag_name && - 'STYLE' !== $tag_name && - 'XMP' !== $tag_name - ) { - return true; - } /* * Preserve the opening tag pointers, as these will be overwritten @@ -938,7 +921,7 @@ public function next_token() { $attributes = $this->attributes; $duplicate_attributes = $this->duplicate_attributes; - // Find the closing tag. + // Find the closing tag if necessary. $found_closer = false; switch ( $tag_name ) { case 'SCRIPT': @@ -950,6 +933,17 @@ public function next_token() { $found_closer = $this->skip_rcdata( $tag_name ); break; + /* + * In the browser this list would include the NOSCRIPT element, + * but the Tag Processor is an environment with the scripting + * flag disabled, meaning that it needs to descend into the + * NOSCRIPT element to be able to properly process what will be + * sent to a browser. + * + * Note that this rule makes HTML5 syntax incompatible with XML, + * because the parsing of this token depends on client application. + * The NOSCRIPT element cannot be represented in the XHTML syntax. + */ case 'IFRAME': case 'NOEMBED': case 'NOFRAMES': @@ -957,6 +951,10 @@ public function next_token() { case 'XMP': $found_closer = $this->skip_rawtext( $tag_name ); break; + + // No other tags should be treated in their entirety here. + default: + return true; } if ( ! $found_closer ) {