Skip to content

Commit 2cfb2d8

Browse files
committed
KSES: Normalize closing block delimiter names. (WordPress#14120)
Trac ticket: Core-66208 See WordPress#13271 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 normalization for all block names inside block delimiters.
1 parent 7119e1b commit 2cfb2d8

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎src/wp-includes/kses.php‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,7 @@ public function sanitize() {
16911691
// Filter block attributes for opening delimiters.
16921692
if ( $block_processor->opens_block() ) {
16931693
$original_attributes = $block_processor->allocate_and_return_parsed_attributes();
1694+
$voider = WP_Block_Processor::VOID === $block_processor->get_delimiter_type() ? '/' : '';
16941695

16951696
if ( isset( $original_attributes ) ) {
16961697
$filtered_attributes = filter_block_kses_value(
@@ -1702,10 +1703,14 @@ public function sanitize() {
17021703

17031704
if ( $original_attributes !== $filtered_attributes ) {
17041705
$serialized_attributes = serialize_block_attributes( $filtered_attributes );
1705-
$voider = WP_Block_Processor::VOID === $block_processor->get_delimiter_type() ? '/' : '';
17061706
$text = " wp:{$implicit_block_type} {$serialized_attributes} {$voider}";
17071707
}
1708+
} elseif ( $block_type !== $implicit_block_type ) {
1709+
$text = " wp:{$implicit_block_type} {$voider}";
17081710
}
1711+
} elseif ( $block_type !== $implicit_block_type ) {
1712+
// Normalize closing block delimiters too.
1713+
$text = " wp:{$implicit_block_type} ";
17091714
}
17101715
}
17111716

0 commit comments

Comments
 (0)