Make WordPress Core


Ignore:
Timestamp:
05/16/2023 03:21:39 PM (17 months ago)
Author:
audrasjb
Message:

Grouped backports to the 5.9 branch.

  • Media: Prevent CSRF setting attachment thumbnails.
  • Embeds: Add protocol validation for WordPress Embed code.
  • I18N: Introduce sanitization function for locale.
  • Editor: Ensure block comments are of a valid form.
  • Editor: Remove shortcode support from block templates.

Merges [55760-55764] to the 5.9 branch.
Props dd32, isabel_brison, martinkrcho, matveb, ocean90, paulkevan, peterwilsoncc, timothyblynjacobs, xknown, youknowriad.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.9/src/wp-includes/blocks.php

    r53019 r55774  
    629629    $result = '';
    630630
     631    if ( false !== strpos( $text, '<!--' ) && false !== strpos( $text, '--->' ) ) {
     632        $text = preg_replace_callback( '%<!--(.*?)--->%', '_filter_block_content_callback', $text );
     633    }
     634
    631635    $blocks = parse_blocks( $text );
    632636    foreach ( $blocks as $block ) {
     
    636640
    637641    return $result;
     642}
     643
     644/**
     645 * Callback used for regular expression replacement in filter_block_content().
     646 *
     647 * @private
     648 * @since 6.2.1
     649 *
     650 * @param array $matches Array of preg_replace_callback matches.
     651 * @return string Replacement string.
     652 */
     653function _filter_block_content_callback( $matches ) {
     654    return '<!--' . rtrim( $matches[1], '-' ) . '-->';
    638655}
    639656
Note: See TracChangeset for help on using the changeset viewer.