Make WordPress Core


Ignore:
Timestamp:
10/12/2023 02:21:47 PM (11 months ago)
Author:
davidbaumwald
Message:

Grouped backports to the 4.1 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.1/src/wp-includes/media.php

    r55772 r56850  
    975975        }
    976976    } elseif ( ! empty( $atts['exclude'] ) ) {
     977        $post_parent_id = $id;
    977978        $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'] ) );
    978979    } else {
     980        $post_parent_id = $id;
    979981        $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
     982    }
     983
     984    if ( ! empty( $post_parent_id ) ) {
     985        $post_parent = get_post( $post_parent_id );
     986
     987        // terminate the shortcode execution if user cannot read the post or password-protected
     988        if (
     989        ( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID ) )
     990        || post_password_required( $post_parent ) ) {
     991            return '';
     992        }
    980993    }
    981994
     
    12691282    }
    12701283
     1284    if ( ! empty( $args['post_parent'] ) ) {
     1285        $post_parent = get_post( $id );
     1286
     1287        // terminate the shortcode execution if user cannot read the post or password-protected
     1288        if ( ! current_user_can( 'read_post', $post_parent->ID ) || post_password_required( $post_parent ) ) {
     1289            return '';
     1290        }
     1291    }
     1292
    12711293    if ( empty( $attachments ) ) {
    12721294        return '';
Note: See TracChangeset for help on using the changeset viewer.