Make WordPress Core

Changeset 56852

Timestamp:
10/12/2023 02:28:05 PM (10 months ago)
Author:
davidbaumwald
Message:

Grouped backports to the 4.3 branch.

  • Comments: Prevent users who can not see a post from seeing comments on it.
  • Shortcodes: Restrict ajax handler for media shortcode.
  • Prevent unintended behavior when certain objects are unserialized.

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

Location:
branches/4.3/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/4.3/src/wp-admin/includes/ajax-actions.php

    r55776 r56852  
    28702870    $shortcode = wp_unslash( $_POST['shortcode'] );
    28712871
     2872
     2873
     2874
     2875
     2876
     2877
     2878
     2879
     2880
     2881
     2882
     2883
     2884
     2885
     2886
     2887
    28722888    if ( ! empty( $_POST['post_ID'] ) ) {
    28732889        $post = get_post( (int) $_POST['post_ID'] );
     
    28762892    // the embed shortcode requires a post
    28772893    if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
    2878         if ( 'embed' === $shortcode ) {
     2894        if ( ) {
    28792895            wp_send_json_error();
    28802896        }
  • branches/4.3/src/wp-admin/includes/class-wp-comments-list-table.php

    r33614 r56852  
    446446        $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
    447447
     448
     449
     450
     451
     452
     453
     454
     455
     456
     457
     458
     459
     460
    448461        echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
    449462        $this->single_row_columns( $comment );
  • branches/4.3/src/wp-admin/includes/class-wp-list-table.php

    r33623 r56852  
    624624        $pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number );
    625625
    626         // No comments at all.
     626        $post_object   = get_post( $post_id );
     627        $edit_post_cap = $post_object ? 'edit_post' : 'edit_posts';
     628        if (
     629            current_user_can( $edit_post_cap, $post_id ) ||
     630            (
     631                empty( $post_object->post_password ) &&
     632                current_user_can( 'read_post', $post_id )
     633            )
     634        ) {
     635            // The user has access to the post and thus can see comments
     636        } else {
     637            return false;
     638        }
     639
    627640        if ( ! $approved_comments && ! $pending_comments ) {
    628641            printf( '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
  • branches/4.3/src/wp-admin/includes/dashboard.php

    r33357 r56852  
    822822
    823823        echo '<div id="the-comment-list" data-wp-lists="list:comment">';
    824         foreach ( $comments as $comment )
    825             _wp_dashboard_recent_comments_row( $comment );
     824        foreach ( $comments as $comment ) {
     825            $comment_post = get_post( $comment->comment_post_ID );
     826            if (
     827                current_user_can( 'edit_post', $comment->comment_post_ID ) ||
     828                (
     829                    empty( $comment_post->post_password ) &&
     830                    current_user_can( 'read_post', $comment->comment_post_ID )
     831                )
     832            ) {
     833                _wp_dashboard_recent_comments_row( $comment );
     834            }
     835        }
    826836        echo '</div>';
    827837
  • branches/4.3/src/wp-includes/class-wp-theme.php

    r39813 r56852  
    508508
    509509    /**
     510
     511
     512
     513
     514
     515
     516
     517
     518
     519
     520
     521
     522
     523
     524
     525
     526
     527
     528
     529
     530
     531
    510532     * Adds theme data to cache.
    511533     *
     
    13041326        return strnatcasecmp( $a->display( 'Name', false, true ), $b->display( 'Name', false, true ) );
    13051327    }
     1328
     1329
     1330
     1331
     1332
     1333
     1334
     1335
     1336
     1337
     1338
     1339
    13061340}
  • branches/4.3/src/wp-includes/media.php

    r55776 r56852  
    10291029        }
    10301030    } elseif ( ! empty( $atts['exclude'] ) ) {
     1031
    10311032        $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'] ) );
    10321033    } else {
     1034
    10331035        $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
     1036
     1037
     1038
     1039
     1040
     1041
     1042
     1043
     1044
     1045
     1046
    10341047    }
    10351048
     
    13271340    }
    13281341
     1342
     1343
     1344
     1345
     1346
     1347
     1348
     1349
     1350
    13291351    if ( empty( $attachments ) ) {
    13301352        return '';
  • branches/4.3/src/wp-includes/shortcodes.php

    r34144 r56852  
    172172
    173173/**
    174  * Search content for shortcodes and filter shortcodes through their hooks.
     174 * Returns a list of registered shortcode names found in the given content.
     175 *
     176 * Example usage:
     177 *
     178 *     get_shortcode_tags_in_content( '[audio src="file.mp3"][/audio] [foo] [gallery ids="1,2,3"]' );
     179 *     // array( 'audio', 'gallery' )
     180 *
     181 * @since 6.3.2
     182 *
     183 * @param string $content The content to check.
     184 * @return string[] An array of registered shortcode names found in the content.
     185 */
     186function get_shortcode_tags_in_content( $content ) {
     187    if ( false === strpos( $content, '[' ) ) {
     188        return array();
     189    }
     190
     191    preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER );
     192    if ( empty( $matches ) ) {
     193        return array();
     194    }
     195
     196    $tags = array();
     197    foreach ( $matches as $shortcode ) {
     198        $tags[] = $shortcode[2];
     199
     200        if ( ! empty( $shortcode[5] ) ) {
     201            $deep_tags = get_shortcode_tags_in_content( $shortcode[5] );
     202            if ( ! empty( $deep_tags ) ) {
     203                $tags = array_merge( $tags, $deep_tags );
     204            }
     205        }
     206    }
     207
     208    return $tags;
     209}
     210
     211/**
     212 * Searches content for shortcodes and filter shortcodes through their hooks.
    175213 *
    176214 * If there are no shortcode tags defined, then the content will be returned
Note: See TracChangeset for help on using the changeset viewer.