Make WordPress Core


Ignore:
Timestamp:
12/12/2019 06:10:56 PM (5 years ago)
Author:
whyisjake
Message:

Prevent stored XSS in the block editor.

Brings r46896 to the 5.3 branch.

Prevent escaped unicode characters become unescaped in unsafe HTML during JSON decoding.

File:
1 edited

Legend:

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

    r46898 r46900  
    49044904
    49054905/**
     4906 * Remove non-allowable HTML from parsed block attribute values when filtering
     4907 * in the post context.
     4908 *
     4909 * @since 5.3.1
     4910 *
     4911 * @param string         $string            Content to be run through KSES.
     4912 * @param array[]|string $allowed_html      An array of allowed HTML elements
     4913 *                                          and attributes, or a context name
     4914 *                                          such as 'post'.
     4915 * @param string[]       $allowed_protocols Array of allowed URL protocols.
     4916 * @return string Filtered text to run through KSES.
     4917 */
     4918function wp_pre_kses_block_attributes( $string, $allowed_html, $allowed_protocols ) {
     4919    /*
     4920     * `filter_block_content` is expected to call `wp_kses`. Temporarily remove
     4921     * the filter to avoid recursion.
     4922     */
     4923    remove_filter( 'pre_kses', 'wp_pre_kses_block_attributes', 10 );
     4924    $string = filter_block_content( $string, $allowed_html, $allowed_protocols );
     4925    add_filter( 'pre_kses', 'wp_pre_kses_block_attributes', 10, 3 );
     4926
     4927    return $string;
     4928}
     4929
     4930/**
    49064931 * WordPress implementation of PHP sprintf() with filters.
    49074932 *
Note: See TracChangeset for help on using the changeset viewer.