Make WordPress Core


Ignore:
Timestamp:
05/16/2023 03:31:04 PM (2 years ago)
Author:
audrasjb
Message:

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

File:
1 edited

Legend:

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

    r51681 r55777  
    621621    $result = '';
    622622
     623    if ( false !== strpos( $text, '<!--' ) && false !== strpos( $text, '--->' ) ) {
     624        $text = preg_replace_callback( '%<!--(.*?)--->%', '_filter_block_content_callback', $text );
     625    }
     626
    623627    $blocks = parse_blocks( $text );
    624628    foreach ( $blocks as $block ) {
     
    628632
    629633    return $result;
     634}
     635
     636/**
     637 * Callback used for regular expression replacement in filter_block_content().
     638 *
     639 * @private
     640 * @since 6.2.1
     641 *
     642 * @param array $matches Array of preg_replace_callback matches.
     643 * @return string Replacement string.
     644 */
     645function _filter_block_content_callback( $matches ) {
     646    return '<!--' . rtrim( $matches[1], '-' ) . '-->';
    630647}
    631648
Note: See TracChangeset for help on using the changeset viewer.