Make WordPress Core


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

Grouped backports to the 4.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.
  • Prevent unintended behavior when certain objects are unserialized.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.4/src/wp-includes/media.php

    r55779 r56855  
    16331633        }
    16341634    } elseif ( ! empty( $atts['exclude'] ) ) {
     1635        $post_parent_id = $id;
    16351636        $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'] ) );
    16361637    } else {
     1638        $post_parent_id = $id;
    16371639        $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
     1640    }
     1641
     1642    if ( ! empty( $post_parent_id ) ) {
     1643        $post_parent = get_post( $post_parent_id );
     1644
     1645        // terminate the shortcode execution if user cannot read the post or password-protected
     1646        if (
     1647        ( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID ) )
     1648        || post_password_required( $post_parent ) ) {
     1649            return '';
     1650        }
    16381651    }
    16391652
     
    19371950    }
    19381951
     1952    if ( ! empty( $args['post_parent'] ) ) {
     1953        $post_parent = get_post( $id );
     1954
     1955        // terminate the shortcode execution if user cannot read the post or password-protected
     1956        if ( ! current_user_can( 'read_post', $post_parent->ID ) || post_password_required( $post_parent ) ) {
     1957            return '';
     1958        }
     1959    }
     1960
    19391961    if ( empty( $attachments ) ) {
    19401962        return '';
Note: See TracChangeset for help on using the changeset viewer.