Make WordPress Core


Ignore:
Timestamp:
10/12/2023 03:06:49 PM (16 months ago)
Author:
davidbaumwald
Message:

Grouped backports to the 5.4 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.4 branch.
Props xknown, jorbin, joehoyle, timothyblynjacobs, peterwilsoncc, ehtis, tykoted, antpb, rmccue.

Location:
branches/5.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.4

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

    r55785 r56878  
    19311931        }
    19321932    } elseif ( ! empty( $atts['exclude'] ) ) {
    1933         $attachments = get_children(
     1933        $post_parent_id = $id;
     1934        $attachments    = get_children(
    19341935            array(
    19351936                'post_parent'    => $id,
     
    19431944        );
    19441945    } else {
    1945         $attachments = get_children(
     1946        $post_parent_id = $id;
     1947        $attachments    = get_children(
    19461948            array(
    19471949                'post_parent'    => $id,
     
    19531955            )
    19541956        );
     1957    }
     1958
     1959    if ( ! empty( $post_parent_id ) ) {
     1960        $post_parent = get_post( $post_parent_id );
     1961
     1962        // terminate the shortcode execution if user cannot read the post or password-protected
     1963        if (
     1964        ( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID ) )
     1965        || post_password_required( $post_parent ) ) {
     1966            return '';
     1967        }
    19551968    }
    19561969
     
    22732286    }
    22742287
     2288    if ( ! empty( $args['post_parent'] ) ) {
     2289        $post_parent = get_post( $id );
     2290
     2291        // terminate the shortcode execution if user cannot read the post or password-protected
     2292        if ( ! current_user_can( 'read_post', $post_parent->ID ) || post_password_required( $post_parent ) ) {
     2293            return '';
     2294        }
     2295    }
     2296
    22752297    if ( empty( $attachments ) ) {
    22762298        return '';
Note: See TracChangeset for help on using the changeset viewer.