From ed654177cdebe231eae83c6fd0dd791043ba77ad Mon Sep 17 00:00:00 2001 From: dmsnell Date: Fri, 27 Sep 2024 00:44:19 +0000 Subject: [PATCH] HTML API: Switch to HTML namespace when entering Integration Points. When encountering inline SVG and MathML content in an HTML document, there are certain "integration points" which transition back into the HTML parsing ruleset. Previously, the HTML API was incorrectly switching into the namespace of the element transitioning into that ruleset. In this patch, the correct transition is made, where all integration points refer to HTML rules, while non-integration points refer to the rules of the namespace corresponding to the token itself. Developed in https://github.com/wordpress/wordpress-develop/pull/7425 Discussed in https://core.trac.wordpress.org/ticket/61576 Props dmsnell, jonsurrell. See #61576. Built from https://develop.svn.wordpress.org/trunk@59099 git-svn-id: http://core.svn.wordpress.org/trunk@58495 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/html-api/class-wp-html-processor.php | 14 ++++++++------ wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/wp-includes/html-api/class-wp-html-processor.php b/wp-includes/html-api/class-wp-html-processor.php index ba8be1e7d4..ed6ac0299b 100644 --- a/wp-includes/html-api/class-wp-html-processor.php +++ b/wp-includes/html-api/class-wp-html-processor.php @@ -393,7 +393,7 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor { $provenance = ( ! $same_node || $is_virtual ) ? 'virtual' : 'real'; $this->element_queue[] = new WP_HTML_Stack_Event( $token, WP_HTML_Stack_Event::PUSH, $provenance ); - $this->change_parsing_namespace( $token->namespace ); + $this->change_parsing_namespace( $token->integration_node_type ? 'html' : $token->namespace ); } ); @@ -403,12 +403,14 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor { $same_node = isset( $this->state->current_token ) && $token->node_name === $this->state->current_token->node_name; $provenance = ( ! $same_node || $is_virtual ) ? 'virtual' : 'real'; $this->element_queue[] = new WP_HTML_Stack_Event( $token, WP_HTML_Stack_Event::POP, $provenance ); + $adjusted_current_node = $this->get_adjusted_current_node(); - $this->change_parsing_namespace( - $adjusted_current_node - ? $adjusted_current_node->namespace - : 'html' - ); + + if ( $adjusted_current_node ) { + $this->change_parsing_namespace( $adjusted_current_node->integration_node_type ? 'html' : $adjusted_current_node->namespace ); + } else { + $this->change_parsing_namespace( 'html' ); + } } ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 1a3bfc7c7f..e42218718a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-alpha-59098'; +$wp_version = '6.7-alpha-59099'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.