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-includes/media.php

    r55775 r56851  
    10111011        }
    10121012    } elseif ( ! empty( $atts['exclude'] ) ) {
     1013        $post_parent_id = $id;
    10131014        $attachments = get_children( array( 'post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
    10141015    } else {
     1016        $post_parent_id = $id;
    10151017        $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
     1018    }
     1019
     1020    if ( ! empty( $post_parent_id ) ) {
     1021        $post_parent = get_post( $post_parent_id );
     1022
     1023        // terminate the shortcode execution if user cannot read the post or password-protected
     1024        if (
     1025        ( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID ) )
     1026        || post_password_required( $post_parent ) ) {
     1027            return '';
     1028        }
    10161029    }
    10171030
     
    13061319    }
    13071320
     1321    if ( ! empty( $args['post_parent'] ) ) {
     1322        $post_parent = get_post( $id );
     1323
     1324        // terminate the shortcode execution if user cannot read the post or password-protected
     1325        if ( ! current_user_can( 'read_post', $post_parent->ID ) || post_password_required( $post_parent ) ) {
     1326            return '';
     1327        }
     1328    }
     1329
    13081330    if ( empty( $attachments ) ) {
    13091331        return '';
Note: See TracChangeset for help on using the changeset viewer.