Make WordPress Core


Ignore:
Timestamp:
10/12/2023 02:25:18 PM (2 years ago)
Author:
davidbaumwald
Message:

Grouped backports to the 4.2 branch.

  • Comments: Prevent users who can not see a post from seeing comments on it.
  • Shortcodes: Restrict ajax handler for media shortcode.
  • Prevent unintended behavior when certain objects are unserialized.

Merges [56835], [56836], and [56838] to the 4.1 branch.
Props xknown, jorbin, joehoyle, peterwilsoncc, ehtis, tykoted, antpb.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2/src/wp-admin/includes/ajax-actions.php

    r55775 r56851  
    28002800    $shortcode = wp_unslash( $_POST['shortcode'] );
    28012801
     2802    // Only process previews for media related shortcodes:
     2803    $found_shortcodes = get_shortcode_tags_in_content( $shortcode );
     2804    $media_shortcodes = array(
     2805        'audio',
     2806        'embed',
     2807        'playlist',
     2808        'video',
     2809        'gallery',
     2810    );
     2811
     2812    $other_shortcodes = array_diff( $found_shortcodes, $media_shortcodes );
     2813
     2814    if ( ! empty( $other_shortcodes ) ) {
     2815        wp_send_json_error();
     2816    }
     2817
    28022818    if ( ! empty( $_POST['post_ID'] ) ) {
    28032819        $post = get_post( (int) $_POST['post_ID'] );
     
    28062822    // the embed shortcode requires a post
    28072823    if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
    2808         if ( 'embed' === $shortcode ) {
     2824        if ( in_array( 'embed', $found_shortcodes, true ) ) {
    28092825            wp_send_json_error();
    28102826        }
Note: See TracChangeset for help on using the changeset viewer.