Make WordPress Core


Ignore:
Timestamp:
05/16/2023 03:43:00 PM (16 months ago)
Author:
audrasjb
Message:

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

File:
1 edited

Legend:

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

    r48629 r55782  
    486486    $result = '';
    487487
     488    if ( false !== strpos( $text, '<!--' ) && false !== strpos( $text, '--->' ) ) {
     489        $text = preg_replace_callback( '%<!--(.*?)--->%', '_filter_block_content_callback', $text );
     490    }
     491
    488492    $blocks = parse_blocks( $text );
    489493    foreach ( $blocks as $block ) {
     
    493497
    494498    return $result;
     499}
     500
     501/**
     502 * Callback used for regular expression replacement in filter_block_content().
     503 *
     504 * @private
     505 * @since 6.2.1
     506 *
     507 * @param array $matches Array of preg_replace_callback matches.
     508 * @return string Replacement string.
     509 */
     510function _filter_block_content_callback( $matches ) {
     511    return '<!--' . rtrim( $matches[1], '-' ) . '-->';
    495512}
    496513
Note: See TracChangeset for help on using the changeset viewer.