Make WordPress Core


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

Grouped backports to the 5.7 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.

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

File:
1 edited

Legend:

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

    r50419 r55778  
    565565    $result = '';
    566566
     567    if ( false !== strpos( $text, '<!--' ) && false !== strpos( $text, '--->' ) ) {
     568        $text = preg_replace_callback( '%<!--(.*?)--->%', '_filter_block_content_callback', $text );
     569    }
     570
    567571    $blocks = parse_blocks( $text );
    568572    foreach ( $blocks as $block ) {
     
    572576
    573577    return $result;
     578}
     579
     580/**
     581 * Callback used for regular expression replacement in filter_block_content().
     582 *
     583 * @private
     584 * @since 6.2.1
     585 *
     586 * @param array $matches Array of preg_replace_callback matches.
     587 * @return string Replacement string.
     588 */
     589function _filter_block_content_callback( $matches ) {
     590    return '<!--' . rtrim( $matches[1], '-' ) . '-->';
    574591}
    575592
Note: See TracChangeset for help on using the changeset viewer.