Make WordPress Core


Ignore:
Timestamp:
05/16/2023 03:54:29 PM (7 months ago)
Author:
audrasjb
Message:

Grouped backports to the 5.3 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.3 branch.
Props dd32, isabel_brison, martinkrcho, matveb, ocean90, paulkevan, peterwilsoncc, timothyblynjacobs, xknown, youknowriad.

File:
1 edited

Legend:

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

    r46900 r55788  
    272272    $result = '';
    273273
     274    if ( false !== strpos( $text, '<!--' ) && false !== strpos( $text, '--->' ) ) {
     275        $text = preg_replace_callback( '%<!--(.*?)--->%', '_filter_block_content_callback', $text );
     276    }
     277
    274278    $blocks = parse_blocks( $text );
    275279    foreach ( $blocks as $block ) {
     
    279283
    280284    return $result;
     285}
     286
     287/**
     288 * Callback used for regular expression replacement in filter_block_content().
     289 *
     290 * @private
     291 * @since 6.2.1
     292 *
     293 * @param array $matches Array of preg_replace_callback matches.
     294 * @return string Replacement string.
     295 */
     296function _filter_block_content_callback( $matches ) {
     297    return '<!--' . rtrim( $matches[1], '-' ) . '-->';
    281298}
    282299
Note: See TracChangeset for help on using the changeset viewer.