Make WordPress Core


Ignore:
Timestamp:
05/16/2023 03:40:27 PM (9 months ago)
Author:
audrasjb
Message:

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

File:
1 edited

Legend:

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

    r49694 r55781  
    488488    $result = '';
    489489
     490    if ( false !== strpos( $text, '<!--' ) && false !== strpos( $text, '--->' ) ) {
     491        $text = preg_replace_callback( '%<!--(.*?)--->%', '_filter_block_content_callback', $text );
     492    }
     493
    490494    $blocks = parse_blocks( $text );
    491495    foreach ( $blocks as $block ) {
     
    495499
    496500    return $result;
     501}
     502
     503/**
     504 * Callback used for regular expression replacement in filter_block_content().
     505 *
     506 * @private
     507 * @since 6.2.1
     508 *
     509 * @param array $matches Array of preg_replace_callback matches.
     510 * @return string Replacement string.
     511 */
     512function _filter_block_content_callback( $matches ) {
     513    return '<!--' . rtrim( $matches[1], '-' ) . '-->';
    497514}
    498515
Note: See TracChangeset for help on using the changeset viewer.