Make WordPress Core


Ignore:
Timestamp:
10/12/2023 02:28:05 PM (3 years ago)
Author:
davidbaumwald
Message:

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

    r55776 r56852  
    10291029                }
    10301030        } elseif ( ! empty( $atts['exclude'] ) ) {
     1031                $post_parent_id = $id;
    10311032                $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'] ) );
    10321033        } else {
     1034                $post_parent_id = $id;
    10331035                $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
     1036        }
     1037
     1038        if ( ! empty( $post_parent_id ) ) {
     1039                $post_parent = get_post( $post_parent_id );
     1040
     1041                // terminate the shortcode execution if user cannot read the post or password-protected
     1042                if (
     1043                ( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID ) )
     1044                || post_password_required( $post_parent ) ) {
     1045                        return '';
     1046                }
    10341047        }
    10351048
    … …  
    13271340        }
    13281341
     1342        if ( ! empty( $args['post_parent'] ) ) {
     1343                $post_parent = get_post( $id );
     1344
     1345                // terminate the shortcode execution if user cannot read the post or password-protected
     1346                if ( ! current_user_can( 'read_post', $post_parent->ID ) || post_password_required( $post_parent ) ) {
     1347                        return '';
     1348                }
     1349        }
     1350
    13291351        if ( empty( $attachments ) ) {
    13301352                return '';
Note: See TracChangeset for help on using the changeset viewer.