From 7d9bb7efd385f87a5b0a6f9d588903a7bf86380e Mon Sep 17 00:00:00 2001 From: dmsnell Date: Wed, 11 Sep 2024 16:13:17 +0000 Subject: [PATCH] HTML API: Make WP_HTML_Processor::get_tag() namespace aware. The HTML specification indicates that an HTML tag with the name "IMAGE" should be renamed as "IMG" and handled as if it were an "IMG", but this only applies to elements in the HTML namespace. In this patch the HTML Processor is updated to ensure that it doesn't remap the tag name when processing foreign content, such as SVG and MathML markup. Developed in https://github.com/wordpress/wordpress-develop/7330 Discussed in https://core.trac.wordpress.org/ticket/61656 Props dmsnell, jonsurrell. See #61576. Built from https://develop.svn.wordpress.org/trunk@59014 git-svn-id: http://core.svn.wordpress.org/trunk@58410 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../html-api/class-wp-html-processor.php | 18 +++++++----------- wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/wp-includes/html-api/class-wp-html-processor.php b/wp-includes/html-api/class-wp-html-processor.php index 0ca7a52a2a..28e5c150a8 100644 --- a/wp-includes/html-api/class-wp-html-processor.php +++ b/wp-includes/html-api/class-wp-html-processor.php @@ -4727,17 +4727,13 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor { $tag_name = parent::get_tag(); - switch ( $tag_name ) { - case 'IMAGE': - /* - * > A start tag whose tag name is "image" - * > Change the token's tag name to "img" and reprocess it. (Don't ask.) - */ - return 'IMG'; - - default: - return $tag_name; - } + /* + * > A start tag whose tag name is "image" + * > Change the token's tag name to "img" and reprocess it. (Don't ask.) + */ + return ( 'IMAGE' === $tag_name && 'html' === $this->get_namespace() ) + ? 'IMG' + : $tag_name; } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 4200c928d8..016652f55b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-alpha-59013'; +$wp_version = '6.7-alpha-59014'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.