Commit 3f2d468e98 for wordpress.org

commit 3f2d468e98aec7b856c6075329b22a98bcb2ab79
Author: dmsnell <dmsnell@git.wordpress.org>
Date:   Fri Oct 9 13:48:52 2026 +0000

    KSES: Normalize all block delimiters.

    When `wp_kses()` was refactored, it introduced block name normalization, but only for opening and void block delimiters whose attributes were changed during sanitization.

    This left semantically-equivalent but mismatched delimiters.

    This patch enforces full normalization for all block delimiters.

    Developed in: https://github.com/WordPress/wordpress-develop/pull/14120
    Discussed in: https://core.trac.wordpress.org/ticket/66208

    Follow-up to: r64233.

    Props dmsnell.
    See #66208.

    Built from https://develop.svn.wordpress.org/trunk@64255


    git-svn-id: http://core.svn.wordpress.org/trunk@63406 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/kses.php b/wp-includes/kses.php
index 0a7ea7ff30..2dddd0f04b 100644
--- a/wp-includes/kses.php
+++ b/wp-includes/kses.php
@@ -1689,24 +1689,29 @@ function wp_sanitize_html_kses( $content, $allowed_html, $allowed_protocols = ar
 							}

 							// Filter block attributes for opening delimiters.
+							$attributes = $block_processor->allocate_and_return_parsed_attributes();
+							$voider     = WP_Block_Processor::VOID === $block_processor->get_delimiter_type() ? '/' : '';
 							if ( $block_processor->opens_block() ) {
-								$original_attributes = $block_processor->allocate_and_return_parsed_attributes();
-
-								if ( isset( $original_attributes ) ) {
-									$filtered_attributes = filter_block_kses_value(
-										$original_attributes,
+								if ( isset( $attributes ) ) {
+									$attributes = filter_block_kses_value(
+										$attributes,
 										$this->specified_allowed_html,
 										$this->allowed_protocols,
 										array( 'blockName' => $block_type )
 									);
-
-									if ( $original_attributes !== $filtered_attributes ) {
-										$serialized_attributes = serialize_block_attributes( $filtered_attributes );
-										$voider                = WP_Block_Processor::VOID === $block_processor->get_delimiter_type() ? '/' : '';
-										$text                  = " wp:{$implicit_block_type} {$serialized_attributes} {$voider}";
-									}
 								}
 							}
+
+							// Fully normalize all block delimiters: name, whitespace, attributes, flags.
+							if ( WP_Block_Processor::CLOSER === $block_processor->get_delimiter_type() ) {
+								$text = " /wp:{$implicit_block_type} ";
+							} elseif ( isset( $attributes ) ) {
+								$serialized_attributes = serialize_block_attributes( $attributes );
+
+								$text = " wp:{$implicit_block_type} {$serialized_attributes} {$voider}";
+							} else {
+								$text = " wp:{$implicit_block_type} {$voider}";
+							}
 						}

 						/*
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 004cc7e79e..9acb40488c 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.2-alpha-64254';
+$wp_version = '7.2-alpha-64255';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.