Make WordPress Core


Ignore:
Timestamp:
10/12/2023 02:34:12 PM (2 years ago)
Author:
davidbaumwald
Message:

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

File:
1 edited

Legend:

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

    r55780 r56857  
    16341634        }
    16351635    } elseif ( ! empty( $atts['exclude'] ) ) {
     1636        $post_parent_id = $id;
    16361637        $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'] ) );
    16371638    } else {
     1639        $post_parent_id = $id;
    16381640        $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
     1641    }
     1642
     1643    if ( ! empty( $post_parent_id ) ) {
     1644        $post_parent = get_post( $post_parent_id );
     1645
     1646        // terminate the shortcode execution if user cannot read the post or password-protected
     1647        if (
     1648        ( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID ) )
     1649        || post_password_required( $post_parent ) ) {
     1650            return '';
     1651        }
    16391652    }
    16401653
     
    19381951    }
    19391952
     1953    if ( ! empty( $args['post_parent'] ) ) {
     1954        $post_parent = get_post( $id );
     1955
     1956        // terminate the shortcode execution if user cannot read the post or password-protected
     1957        if ( ! current_user_can( 'read_post', $post_parent->ID ) || post_password_required( $post_parent ) ) {
     1958            return '';
     1959        }
     1960    }
     1961
    19401962    if ( empty( $attachments ) ) {
    19411963        return '';
Note: See TracChangeset for help on using the changeset viewer.