Make WordPress Core


Ignore:
Timestamp:
10/12/2023 02:43:19 PM (8 months ago)
Author:
davidbaumwald
Message:

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

File:
1 edited

Legend:

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

    r55783 r56859  
    16601660        }
    16611661    } elseif ( ! empty( $atts['exclude'] ) ) {
     1662        $post_parent_id = $id;
    16621663        $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'] ) );
    16631664    } else {
     1665        $post_parent_id = $id;
    16641666        $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
     1667    }
     1668
     1669    if ( ! empty( $post_parent_id ) ) {
     1670        $post_parent = get_post( $post_parent_id );
     1671
     1672        // terminate the shortcode execution if user cannot read the post or password-protected
     1673        if (
     1674        ( ! is_post_publicly_viewable( $post_parent->ID ) && ! current_user_can( 'read_post', $post_parent->ID ) )
     1675        || post_password_required( $post_parent ) ) {
     1676            return '';
     1677        }
    16651678    }
    16661679
     
    19641977    }
    19651978
     1979    if ( ! empty( $args['post_parent'] ) ) {
     1980        $post_parent = get_post( $id );
     1981
     1982        // terminate the shortcode execution if user cannot read the post or password-protected
     1983        if ( ! current_user_can( 'read_post', $post_parent->ID ) || post_password_required( $post_parent ) ) {
     1984            return '';
     1985        }
     1986    }
     1987
    19661988    if ( empty( $attachments ) ) {
    19671989        return '';
Note: See TracChangeset for help on using the changeset viewer.