Make WordPress Core

Changeset 56884

Timestamp:
10/12/2023 03:14:45 PM (10 months ago)
Author:
joemcgill
Message:

Grouped backports to the 5.8 branch.

  • REST API: Limit search_columns for users without list_users.
  • Comments: Prevent users who can not see a post from seeing comments on it.
  • Application Passwords: Prevent the use of some pseudo protocols in application passwords.
  • Restrict media shortcode ajax to certain type
  • REST API: Ensure no-cache headers are sent when methods are overriden.
  • Prevent unintended behavior when certain objects are unserialized.

Merges [56833], [56834], [56835], [56836], [56837], and [56838] to the 5.8 branch.
Props xknown, jorbin, Vortfu, joehoyle, timothyblynjacobs, peterwilsoncc, ehtis, tykoted, martinkrcho, paulkevan, dd32, antpb, rmccue.

Location:
branches/5.8
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • branches/5.8

  • branches/5.8/src/wp-admin/includes/ajax-actions.php

    r55777 r56884  
    37833783    $shortcode = wp_unslash( $_POST['shortcode'] );
    37843784
     3785
     3786
     3787
     3788
     3789
     3790
     3791
     3792
     3793
     3794
     3795
     3796
     3797
     3798
     3799
     3800
    37853801    if ( ! empty( $_POST['post_ID'] ) ) {
    37863802        $post = get_post( (int) $_POST['post_ID'] );
     
    37893805    // The embed shortcode requires a post.
    37903806    if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
    3791         if ( 'embed' === $shortcode ) {
     3807        if ( ) {
    37923808            wp_send_json_error();
    37933809        }
  • branches/5.8/src/wp-admin/includes/class-wp-comments-list-table.php

    r50805 r56884  
    640640
    641641        $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
     642
     643
     644
     645
     646
     647
     648
     649
     650
     651
     652
     653
     654
    642655
    643656        echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
  • branches/5.8/src/wp-admin/includes/class-wp-list-table.php

    r51115 r56884  
    735735            $pending_comments_number
    736736        );
     737
     738
     739
     740
     741
     742
     743
     744
     745
     746
     747
     748
     749
     750
    737751
    738752        if ( ! $approved_comments && ! $pending_comments ) {
  • branches/5.8/src/wp-admin/includes/dashboard.php

    r51313 r56884  
    10861086        echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
    10871087        foreach ( $comments as $comment ) {
    1088             _wp_dashboard_recent_comments_row( $comment );
     1088
     1089            $comment_post = get_post( $comment->comment_post_ID );
     1090            if (
     1091                current_user_can( 'edit_post', $comment->comment_post_ID ) ||
     1092                (
     1093                    empty( $comment_post->post_password ) &&
     1094                    current_user_can( 'read_post', $comment->comment_post_ID )
     1095                )
     1096            ) {
     1097                _wp_dashboard_recent_comments_row( $comment );
     1098            }
    10891099        }
    10901100        echo '</ul>';
  • branches/5.8/src/wp-admin/includes/user.php

    r50981 r56884  
    600600 *
    601601 * @since 5.6.0
     602
     603
    602604 *
    603605 * @param array   $request {
     
    615617    $error = new WP_Error();
    616618
    617     if ( ! empty( $request['success_url'] ) ) {
    618         $scheme = wp_parse_url( $request['success_url'], PHP_URL_SCHEME );
    619 
    620         if ( 'http' === $scheme ) {
     619    if ( isset( $request['success_url'] ) ) {
     620        $validated_success_url = wp_is_authorize_application_redirect_url_valid( $request['success_url'] );
     621        if ( is_wp_error( $validated_success_url ) ) {
    621622            $error->add(
    622                 'invalid_redirect_scheme',
    623                 __( 'The success url must be served over a secure connection.' )
     623                ,
     624                )
    624625            );
    625626        }
    626627    }
    627628
    628     if ( ! empty( $request['reject_url'] ) ) {
    629         $scheme = wp_parse_url( $request['reject_url'], PHP_URL_SCHEME );
    630 
    631         if ( 'http' === $scheme ) {
     629    if ( isset( $request['reject_url'] ) ) {
     630        $validated_reject_url = wp_is_authorize_application_redirect_url_valid( $request['reject_url'] );
     631        if ( is_wp_error( $validated_reject_url ) ) {
    632632            $error->add(
    633                 'invalid_redirect_scheme',
    634                 __( 'The rejection url must be served over a secure connection.' )
     633                ,
     634                )
    635635            );
    636636        }
     
    661661    return true;
    662662}
     663
     664
     665
     666
     667
     668
     669
     670
     671
     672
     673
     674
     675
     676
     677
     678
     679
     680
     681
     682
     683
     684
     685
     686
     687
     688
     689
     690
     691
     692
     693
     694
     695
     696
     697
     698
     699
     700
     701
     702
     703
     704
     705
     706
     707
     708
     709
     710
     711
     712
     713
     714
     715
     716
     717
     718
  • branches/5.8/src/wp-includes/Requests/Hooks.php

    r50842 r56884  
    6666        return true;
    6767    }
     68
     69
     70
     71
    6872}
  • branches/5.8/src/wp-includes/Requests/IRI.php

    r50842 r56884  
    706706    }
    707707
     708
     709
     710
     711
     712
     713
     714
     715
     716
     717
     718
     719
     720
     721
    708722    /**
    709723     * Set the entire IRI. Returns true on success, false on failure (if there
  • branches/5.8/src/wp-includes/Requests/Session.php

    r50842 r56884  
    230230    }
    231231
     232
     233
     234
     235
    232236    /**
    233237     * Merge a request's data with the default data
  • branches/5.8/src/wp-includes/class-wp-block-patterns-registry.php

    r51154 r56884  
    140140    }
    141141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
    142157    /**
    143158     * Utility method to retrieve the main instance of the class.
  • branches/5.8/src/wp-includes/class-wp-block-type-registry.php

    r51154 r56884  
    168168    }
    169169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
    170184    /**
    171185     * Utility method to retrieve the main instance of the class.
  • branches/5.8/src/wp-includes/class-wp-theme.php

    r51003 r56884  
    677677
    678678    /**
     679
     680
     681
     682
     683
     684
     685
     686
     687
     688
     689
     690
     691
     692
     693
     694
     695
     696
     697
     698
     699
     700
    679701     * Adds theme data to cache.
    680702     *
     
    16761698        return strnatcasecmp( $a->name_translated, $b->name_translated );
    16771699    }
     1700
     1701
     1702
     1703
     1704
     1705
     1706
     1707
     1708
     1709
     1710
     1711
    16781712}
  • branches/5.8/src/wp-includes/media.php

    r55777 r56884  
    23392339        }
    23402340    } elseif ( ! empty( $atts['exclude'] ) ) {
     2341
    23412342        $attachments = get_children(
    23422343            array(
     
    23512352        );
    23522353    } else {
     2354
    23532355        $attachments = get_children(
    23542356            array(
     
    23612363            )
    23622364        );
     2365
     2366
     2367
     2368
     2369
     2370
     2371
     2372
     2373
     2374
     2375
    23632376    }
    23642377
     
    26892702    }
    26902703
     2704
     2705
     2706
     2707
     2708
     2709
     2710
     2711
     2712
    26912713    if ( empty( $attachments ) ) {
    26922714        return '';
  • branches/5.8/src/wp-includes/rest-api.php

    r51021 r56884  
    10291029
    10301030    if ( ! $result ) {
     1031
    10311032        return new WP_Error( 'rest_cookie_invalid_nonce', __( 'Cookie check failed' ), array( 'status' => 403 ) );
    10321033    }
  • branches/5.8/src/wp-includes/rest-api/class-wp-rest-server.php

    r51317 r56884  
    332332
    333333        /**
    334          * Filters whether to send nocache headers on a REST API request.
    335          *
    336          * @since 4.4.0
    337          *
    338          * @param bool $rest_send_nocache_headers Whether to send no-cache headers.
    339          */
    340         $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() );
    341         if ( $send_no_cache_headers ) {
    342             foreach ( wp_get_nocache_headers() as $header => $header_value ) {
    343                 if ( empty( $header_value ) ) {
    344                     $this->remove_header( $header );
    345                 } else {
    346                     $this->send_header( $header, $header_value );
    347                 }
    348             }
    349         }
    350 
    351         /**
    352334         * Filters whether the REST API is enabled.
    353335         *
     
    403385         * header.
    404386         */
     387
    405388        if ( isset( $_GET['_method'] ) ) {
    406389            $request->set_method( $_GET['_method'] );
    407390        } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) {
    408391            $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] );
     392
    409393        }
    410394
     
    464448         */
    465449        $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this );
     450
     451
     452
     453
     454
     455
     456
     457
     458
     459
     460
     461
     462
     463
     464
     465
     466
     467
     468
     469
     470
     471
    466472
    467473        if ( ! $served ) {
  • branches/5.8/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

    r51000 r56884  
    303303
    304304        if ( ! empty( $prepared_args['search'] ) ) {
     305
     306
     307
    305308            $prepared_args['search'] = '*' . $prepared_args['search'] . '*';
    306309        }
  • branches/5.8/src/wp-includes/shortcodes.php

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