Make WordPress Core


Ignore:
Timestamp:
10/12/2023 03:04:07 PM (17 months ago)
Author:
davidbaumwald
Message:

Grouped backports to the 5.2 branch.

  • Comments: Prevent users who can not see a post from seeing comments on it.
  • Shortcodes: Restrict media shortcode ajax to certain type.
  • REST API: Ensure no-cache headers are sent when methods are overridden.
  • REST API: Limit search_columns for users without list_users.
  • Prevent unintended behavior when certain objects are unserialized.

Merges [56833], [56834], [56835], [56836], and [56838] to the 5.2 branch.
Props xknown, jorbin, joehoyle, timothyblynjacobs, peterwilsoncc, ehtis, tykoted, antpb, rmccue.

Location:
branches/5.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.2

  • branches/5.2/src/wp-includes/media.php

    r55789 r56876  
    17481748        }
    17491749    } elseif ( ! empty( $atts['exclude'] ) ) {
    1750         $attachments = get_children(
     1750        $post_parent_id = $id;
     1751        $attachments    = get_children(
    17511752            array(
    17521753                'post_parent'    => $id,
     
    17601761        );
    17611762    } else {
    1762         $attachments = get_children(
     1763        $post_parent_id = $id;
     1764        $attachments    = get_children(
    17631765            array(
    17641766                'post_parent'    => $id,
     
    17701772            )
    17711773        );
     1774    }
     1775
     1776    if ( ! empty( $post_parent_id ) ) {
     1777        $post_parent = get_post( $post_parent_id );
     1778
     1779        // terminate the shortcode execution if user cannot read the post or password-protected
     1780        if (
     1781        ( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID ) )
     1782        || post_password_required( $post_parent ) ) {
     1783            return '';
     1784        }
    17721785    }
    17731786
     
    20792092    }
    20802093
     2094    if ( ! empty( $args['post_parent'] ) ) {
     2095        $post_parent = get_post( $id );
     2096
     2097        // terminate the shortcode execution if user cannot read the post or password-protected
     2098        if ( ! current_user_can( 'read_post', $post_parent->ID ) || post_password_required( $post_parent ) ) {
     2099            return '';
     2100        }
     2101    }
     2102
    20812103    if ( empty( $attachments ) ) {
    20822104        return '';
Note: See TracChangeset for help on using the changeset viewer.