Make WordPress Core

Changeset 56851

Timestamp:
10/12/2023 02:25:18 PM (10 months ago)
Author:
davidbaumwald
Message:

Grouped backports to the 4.2 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.2/src
Files:
7 edited

Legend:

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

    r55775 r56851  
    28002800    $shortcode = wp_unslash( $_POST['shortcode'] );
    28012801
     2802
     2803
     2804
     2805
     2806
     2807
     2808
     2809
     2810
     2811
     2812
     2813
     2814
     2815
     2816
     2817
    28022818    if ( ! empty( $_POST['post_ID'] ) ) {
    28032819        $post = get_post( (int) $_POST['post_ID'] );
     
    28062822    // the embed shortcode requires a post
    28072823    if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
    2808         if ( 'embed' === $shortcode ) {
     2824        if ( ) {
    28092825            wp_send_json_error();
    28102826        }
  • branches/4.2/src/wp-admin/includes/class-wp-comments-list-table.php

    r32175 r56851  
    371371        $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
    372372
     373
     374
     375
     376
     377
     378
     379
     380
     381
     382
     383
     384
     385
    373386        echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
    374387        $this->single_row_columns( $comment );
  • branches/4.2/src/wp-admin/includes/class-wp-list-table.php

    r31513 r56851  
    610610        $pending_phrase = sprintf( __( '%s pending' ), number_format( $pending_comments ) );
    611611
     612
     613
     614
     615
     616
     617
     618
     619
     620
     621
     622
     623
     624
     625
    612626        if ( $pending_comments )
    613627            echo '<strong>';
  • branches/4.2/src/wp-admin/includes/dashboard.php

    r33358 r56851  
    787787
    788788        echo '<div id="the-comment-list" data-wp-lists="list:comment">';
    789         foreach ( $comments as $comment )
    790             _wp_dashboard_recent_comments_row( $comment );
     789        foreach ( $comments as $comment ) {
     790            $comment_post = get_post( $comment->comment_post_ID );
     791            if (
     792                current_user_can( 'edit_post', $comment->comment_post_ID ) ||
     793                (
     794                    empty( $comment_post->post_password ) &&
     795                    current_user_can( 'read_post', $comment->comment_post_ID )
     796                )
     797            ) {
     798                _wp_dashboard_recent_comments_row( $comment );
     799            }
     800        }
    791801        echo '</div>';
    792802
  • branches/4.2/src/wp-includes/class-wp-theme.php

    r39814 r56851  
    478478
    479479    /**
     480
     481
     482
     483
     484
     485
     486
     487
     488
     489
     490
     491
     492
     493
     494
     495
     496
     497
     498
     499
     500
     501
    480502     * Adds theme data to cache.
    481503     *
     
    12361258        return strnatcasecmp( $a->display( 'Name', false, true ), $b->display( 'Name', false, true ) );
    12371259    }
     1260
     1261
     1262
     1263
     1264
     1265
     1266
     1267
     1268
     1269
     1270
     1271
    12381272}
  • branches/4.2/src/wp-includes/media.php

    r55775 r56851  
    10111011        }
    10121012    } elseif ( ! empty( $atts['exclude'] ) ) {
     1013
    10131014        $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'] ) );
    10141015    } else {
     1016
    10151017        $attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
     1018
     1019
     1020
     1021
     1022
     1023
     1024
     1025
     1026
     1027
     1028
    10161029    }
    10171030
     
    13061319    }
    13071320
     1321
     1322
     1323
     1324
     1325
     1326
     1327
     1328
     1329
    13081330    if ( empty( $attachments ) ) {
    13091331        return '';
  • branches/4.2/src/wp-includes/shortcodes.php

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