Changeset 58483 for branches/5.9/src/wp-includes/blocks.php
- Timestamp:
- 06/24/2024 03:23:25 PM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.9/src/wp-includes/blocks.php
r55774 r58483 669 669 */ 670 670 function filter_block_kses( $block, $allowed_html, $allowed_protocols = array() ) { 671 $block['attrs'] = filter_block_kses_value( $block['attrs'], $allowed_html, $allowed_protocols );671 $block['attrs'] = filter_block_kses_value( $block['attrs'], $allowed_html, $allowed_protocols, $block ); 672 672 673 673 if ( is_array( $block['innerBlocks'] ) ) { … … 685 685 * 686 686 * @since 5.3.1 687 * @since 6.5.5 Added the `$block_context` parameter. 687 688 * 688 689 * @param string[]|string $value The attribute value to filter. … … 691 692 * such as 'post'. 692 693 * @param string[] $allowed_protocols Array of allowed URL protocols. 694 * @param array $block_context Optional. The block the attribute belongs to, in parsed block array format. 693 695 * @return string[]|string The filtered and sanitized result. 694 696 */ 695 function filter_block_kses_value( $value, $allowed_html, $allowed_protocols = array() ) {697 function filter_block_kses_value( $value, $allowed_html, $allowed_protocols = array(), $block_context = null ) { 696 698 if ( is_array( $value ) ) { 697 699 foreach ( $value as $key => $inner_value ) { 698 $filtered_key = filter_block_kses_value( $key, $allowed_html, $allowed_protocols ); 699 $filtered_value = filter_block_kses_value( $inner_value, $allowed_html, $allowed_protocols ); 700 $filtered_key = filter_block_kses_value( $key, $allowed_html, $allowed_protocols, $block_context ); 701 $filtered_value = filter_block_kses_value( $inner_value, $allowed_html, $allowed_protocols, $block_context ); 702 703 if ( isset( $block_context['blockName'] ) && 'core/template-part' === $block_context['blockName'] ) { 704 $filtered_value = filter_block_core_template_part_attributes( $filtered_value, $filtered_key, $allowed_html ); 705 } 700 706 701 707 if ( $filtered_key !== $key ) { … … 710 716 711 717 return $value; 718 } 719 720 /** 721 * Sanitizes the value of the Template Part block's `tagName` attribute. 722 * 723 * @since 6.5.5 724 * 725 * @param string $attribute_value The attribute value to filter. 726 * @param string $attribute_name The attribute name. 727 * @param array[]|string $allowed_html An array of allowed HTML elements and attributes, 728 * or a context name such as 'post'. See wp_kses_allowed_html() 729 * for the list of accepted context names. 730 * @return string The sanitized attribute value. 731 */ 732 function filter_block_core_template_part_attributes( $attribute_value, $attribute_name, $allowed_html ) { 733 if ( empty( $attribute_value ) || 'tagName' !== $attribute_name ) { 734 return $attribute_value; 735 } 736 if ( ! is_array( $allowed_html ) ) { 737 $allowed_html = wp_kses_allowed_html( $allowed_html ); 738 } 739 return isset( $allowed_html[ $attribute_value ] ) ? $attribute_value : ''; 712 740 } 713 741
Note: See TracChangeset
for help on using the changeset viewer.