Make WordPress Core

Changeset 56895

Timestamp:
10/12/2023 04:07:43 PM (10 months ago)
Author:
joemcgill
Message:

Grouped backports to the 6.2 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 6.2 branch.
Props xknown, jorbin, Vortfu, joehoyle, timothyblynjacobs, peterwilsoncc, ehtis, tykoted, martinkrcho, paulkevan, dd32, antpb, rmccue.

Location:
branches/6.2
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • branches/6.2

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

    r55769 r56895  
    38563856    $shortcode = wp_unslash( $_POST['shortcode'] );
    38573857
     3858
     3859
     3860
     3861
     3862
     3863
     3864
     3865
     3866
     3867
     3868
     3869
     3870
     3871
     3872
     3873
    38583874    if ( ! empty( $_POST['post_ID'] ) ) {
    38593875        $post = get_post( (int) $_POST['post_ID'] );
     
    38623878    // The embed shortcode requires a post.
    38633879    if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
    3864         if ( 'embed' === $shortcode ) {
     3880        if ( ) {
    38653881            wp_send_json_error();
    38663882        }
  • branches/6.2/src/wp-admin/includes/class-wp-comments-list-table.php

    r55276 r56895  
    641641
    642642        $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
     643
     644
     645
     646
     647
     648
     649
     650
     651
     652
     653
     654
     655
    643656
    644657        echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
  • branches/6.2/src/wp-admin/includes/class-wp-list-table.php

    r55293 r56895  
    818818            $pending_comments_number
    819819        );
     820
     821
     822
     823
     824
     825
     826
     827
     828
     829
     830
     831
     832
     833
    820834
    821835        if ( ! $approved_comments && ! $pending_comments ) {
  • branches/6.2/src/wp-admin/includes/dashboard.php

    r55576 r56895  
    11021102        echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
    11031103        foreach ( $comments as $comment ) {
    1104             _wp_dashboard_recent_comments_row( $comment );
     1104
     1105            $comment_post = get_post( $comment->comment_post_ID );
     1106            if (
     1107                current_user_can( 'edit_post', $comment->comment_post_ID ) ||
     1108                (
     1109                    empty( $comment_post->post_password ) &&
     1110                    current_user_can( 'read_post', $comment->comment_post_ID )
     1111                )
     1112            ) {
     1113                _wp_dashboard_recent_comments_row( $comment );
     1114            }
    11051115        }
    11061116        echo '</ul>';
  • branches/6.2/src/wp-admin/includes/user.php

    r55283 r56895  
    614614 * @since 5.6.0
    615615 * @since 6.2.0 Allow insecure HTTP connections for the local environment.
     616
    616617 *
    617618 * @param array   $request {
     
    627628 */
    628629function wp_is_authorize_application_password_request_valid( $request, $user ) {
    629     $error    = new WP_Error();
    630     $is_local = 'local' === wp_get_environment_type();
    631 
    632     if ( ! empty( $request['success_url'] ) ) {
    633         $scheme = wp_parse_url( $request['success_url'], PHP_URL_SCHEME );
    634 
    635         if ( 'http' === $scheme && ! $is_local ) {
     630    $error = new WP_Error();
     631
     632    if ( isset( $request['success_url'] ) ) {
     633        $validated_success_url = wp_is_authorize_application_redirect_url_valid( $request['success_url'] );
     634        if ( is_wp_error( $validated_success_url ) ) {
    636635            $error->add(
    637                 'invalid_redirect_scheme',
    638                 __( 'The success URL must be served over a secure connection.' )
     636                ,
     637                )
    639638            );
    640639        }
    641640    }
    642641
    643     if ( ! empty( $request['reject_url'] ) ) {
    644         $scheme = wp_parse_url( $request['reject_url'], PHP_URL_SCHEME );
    645 
    646         if ( 'http' === $scheme && ! $is_local ) {
     642    if ( isset( $request['reject_url'] ) ) {
     643        $validated_reject_url = wp_is_authorize_application_redirect_url_valid( $request['reject_url'] );
     644        if ( is_wp_error( $validated_reject_url ) ) {
    647645            $error->add(
    648                 'invalid_redirect_scheme',
    649                 __( 'The rejection URL must be served over a secure connection.' )
     646                ,
     647                )
    650648            );
    651649        }
     
    676674    return true;
    677675}
     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
     719
     720
     721
     722
     723
     724
     725
     726
     727
     728
     729
     730
     731
  • branches/6.2/src/wp-includes/Requests/src/Hooks.php

    r54997 r56895  
    9797        return true;
    9898    }
     99
     100
     101
     102
    99103}
  • branches/6.2/src/wp-includes/Requests/src/Iri.php

    r54997 r56895  
    718718    }
    719719
     720
     721
     722
     723
     724
     725
     726
     727
     728
     729
     730
     731
     732
     733
    720734    /**
    721735     * Set the entire IRI. Returns true on success, false on failure (if there
  • branches/6.2/src/wp-includes/Requests/src/Session.php

    r54997 r56895  
    266266    }
    267267
     268
     269
     270
     271
    268272    /**
    269273     * Merge a request's data with the default data
  • branches/6.2/src/wp-includes/class-wp-block-patterns-registry.php

    r55174 r56895  
    198198    }
    199199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
    200215    /**
    201216     * Utility method to retrieve the main instance of the class.
  • branches/6.2/src/wp-includes/class-wp-block-type-registry.php

    r54133 r56895  
    169169    }
    170170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
    171185    /**
    172186     * Utility method to retrieve the main instance of the class.
  • branches/6.2/src/wp-includes/class-wp-theme.php

    r55426 r56895  
    741741
    742742    /**
     743
     744
     745
     746
     747
     748
     749
     750
     751
     752
     753
     754
     755
     756
     757
     758
     759
     760
     761
     762
     763
     764
    743765     * Adds theme data to cache.
    744766     *
     
    18091831        return strnatcasecmp( $a->name_translated, $b->name_translated );
    18101832    }
     1833
     1834
     1835
     1836
     1837
     1838
     1839
     1840
     1841
     1842
     1843
     1844
    18111845}
  • branches/6.2/src/wp-includes/media.php

    r55769 r56895  
    24602460        }
    24612461    } elseif ( ! empty( $atts['exclude'] ) ) {
     2462
    24622463        $attachments = get_children(
    24632464            array(
     
    24722473        );
    24732474    } else {
     2475
    24742476        $attachments = get_children(
    24752477            array(
     
    24822484            )
    24832485        );
     2486
     2487
     2488
     2489
     2490
     2491
     2492
     2493
     2494
     2495
     2496
    24842497    }
    24852498
     
    28162829    }
    28172830
     2831
     2832
     2833
     2834
     2835
     2836
     2837
     2838
     2839
    28182840    if ( empty( $attachments ) ) {
    28192841        return '';
  • branches/6.2/src/wp-includes/rest-api.php

    r55293 r56895  
    10691069
    10701070    if ( ! $result ) {
     1071
    10711072        return new WP_Error( 'rest_cookie_invalid_nonce', __( 'Cookie check failed' ), array( 'status' => 403 ) );
    10721073    }
  • branches/6.2/src/wp-includes/rest-api/class-wp-rest-server.php

    r55361 r56895  
    360360
    361361        /**
    362          * Filters whether to send nocache headers on a REST API request.
    363          *
    364          * @since 4.4.0
    365          *
    366          * @param bool $rest_send_nocache_headers Whether to send no-cache headers.
    367          */
    368         $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() );
    369         if ( $send_no_cache_headers ) {
    370             foreach ( wp_get_nocache_headers() as $header => $header_value ) {
    371                 if ( empty( $header_value ) ) {
    372                     $this->remove_header( $header );
    373                 } else {
    374                     $this->send_header( $header, $header_value );
    375                 }
    376             }
    377         }
    378 
    379         /**
    380362         * Filters whether the REST API is enabled.
    381363         *
     
    431413         * header.
    432414         */
     415
    433416        if ( isset( $_GET['_method'] ) ) {
    434417            $request->set_method( $_GET['_method'] );
    435418        } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) {
    436419            $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] );
     420
    437421        }
    438422
     
    493477         */
    494478        $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this );
     479
     480
     481
     482
     483
     484
     485
     486
     487
     488
     489
     490
     491
     492
     493
     494
     495
     496
     497
     498
     499
     500
    495501
    496502        if ( ! $served ) {
  • branches/6.2/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

    r55325 r56895  
    319319
    320320        if ( ! empty( $prepared_args['search'] ) ) {
     321
     322
     323
    321324            $prepared_args['search'] = '*' . $prepared_args['search'] . '*';
    322325        }
  • branches/6.2/src/wp-includes/shortcodes.php

    r55119 r56895  
    167167    }
    168168    return false;
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
     190
     191
     192
     193
     194
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
    169207}
    170208
Note: See TracChangeset for help on using the changeset viewer.