Make WordPress Core

Changeset 56882

Timestamp:
10/12/2023 03:12:09 PM (10 months ago)
Author:
davidbaumwald
Message:

Grouped backports to the 5.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.
  • REST API: Limit search_columns for users without list_users.
  • Prevent unintended behavior when certain objects are unserialized.
  • Application Passwords: Prevent the use of some pseudo protocols in application passwords.

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

Location:
branches/5.6
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • branches/5.6

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

    r55781 r56882  
    37673767    $shortcode = wp_unslash( $_POST['shortcode'] );
    37683768
     3769
     3770
     3771
     3772
     3773
     3774
     3775
     3776
     3777
     3778
     3779
     3780
     3781
     3782
     3783
     3784
    37693785    if ( ! empty( $_POST['post_ID'] ) ) {
    37703786        $post = get_post( (int) $_POST['post_ID'] );
     
    37733789    // The embed shortcode requires a post.
    37743790    if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
    3775         if ( 'embed' === $shortcode ) {
     3791        if ( ) {
    37763792            wp_send_json_error();
    37773793        }
  • branches/5.6/src/wp-admin/includes/class-wp-comments-list-table.php

    r49193 r56882  
    622622        }
    623623        $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
     624
     625
     626
     627
     628
     629
     630
     631
     632
     633
     634
     635
     636
    624637
    625638        echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
  • branches/5.6/src/wp-admin/includes/class-wp-list-table.php

    r49599 r56882  
    727727            $pending_comments_number
    728728        );
     729
     730
     731
     732
     733
     734
     735
     736
     737
     738
     739
     740
     741
     742
    729743
    730744        if ( ! $approved_comments && ! $pending_comments ) {
  • branches/5.6/src/wp-admin/includes/dashboard.php

    r50059 r56882  
    10531053        echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
    10541054        foreach ( $comments as $comment ) {
    1055             _wp_dashboard_recent_comments_row( $comment );
     1055
     1056            $comment_post = get_post( $comment->comment_post_ID );
     1057            if (
     1058                current_user_can( 'edit_post', $comment->comment_post_ID ) ||
     1059                (
     1060                    empty( $comment_post->post_password ) &&
     1061                    current_user_can( 'read_post', $comment->comment_post_ID )
     1062                )
     1063            ) {
     1064                _wp_dashboard_recent_comments_row( $comment );
     1065            }
    10561066        }
    10571067        echo '</ul>';
  • branches/5.6/src/wp-admin/includes/user.php

    r49276 r56882  
    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.6/src/wp-includes/Requests/Hooks.php

    r46586 r56882  
    6666        return true;
    6767    }
     68
     69
     70
     71
    6872}
  • branches/5.6/src/wp-includes/Requests/IRI.php

    r46586 r56882  
    704704    }
    705705
     706
     707
     708
     709
     710
     711
     712
     713
     714
     715
     716
     717
     718
     719
    706720    /**
    707721     * Set the entire IRI. Returns true on success, false on failure (if there
  • branches/5.6/src/wp-includes/Requests/Session.php

    r46586 r56882  
    228228    }
    229229
     230
     231
     232
     233
    230234    /**
    231235     * Merge a request's data with the default data
  • branches/5.6/src/wp-includes/class-wp-block-patterns-registry.php

    r49311 r56882  
    125125    }
    126126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
    127142    /**
    128143     * Utility method to retrieve the main instance of the class.
  • branches/5.6/src/wp-includes/class-wp-block-type-registry.php

    r48629 r56882  
    156156    }
    157157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
    158172    /**
    159173     * Utility method to retrieve the main instance of the class.
  • branches/5.6/src/wp-includes/class-wp-theme.php

    r49220 r56882  
    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     *
     
    16601682        return strnatcasecmp( $a->name_translated, $b->name_translated );
    16611683    }
     1684
     1685
     1686
     1687
     1688
     1689
     1690
     1691
     1692
     1693
     1694
     1695
    16621696}
  • branches/5.6/src/wp-includes/media.php

    r55781 r56882  
    22492249        }
    22502250    } elseif ( ! empty( $atts['exclude'] ) ) {
     2251
    22512252        $attachments = get_children(
    22522253            array(
     
    22612262        );
    22622263    } else {
     2264
    22632265        $attachments = get_children(
    22642266            array(
     
    22712273            )
    22722274        );
     2275
     2276
     2277
     2278
     2279
     2280
     2281
     2282
     2283
     2284
     2285
    22732286    }
    22742287
     
    25992612    }
    26002613
     2614
     2615
     2616
     2617
     2618
     2619
     2620
     2621
     2622
    26012623    if ( empty( $attachments ) ) {
    26022624        return '';
  • branches/5.6/src/wp-includes/rest-api.php

    r49611 r56882  
    10131013
    10141014    if ( ! $result ) {
     1015
    10151016        return new WP_Error( 'rest_cookie_invalid_nonce', __( 'Cookie nonce is invalid' ), array( 'status' => 403 ) );
    10161017    }
  • branches/5.6/src/wp-includes/rest-api/class-wp-rest-server.php

    r49610 r56882  
    346346
    347347        /**
    348          * Send nocache headers on authenticated requests.
    349          *
    350          * @since 4.4.0
    351          *
    352          * @param bool $rest_send_nocache_headers Whether to send no-cache headers.
    353          */
    354         $send_no_cache_headers = apply_filters( 'rest_send_nocache_headers', is_user_logged_in() );
    355         if ( $send_no_cache_headers ) {
    356             foreach ( wp_get_nocache_headers() as $header => $header_value ) {
    357                 if ( empty( $header_value ) ) {
    358                     $this->remove_header( $header );
    359                 } else {
    360                     $this->send_header( $header, $header_value );
    361                 }
    362             }
    363         }
    364 
    365         /**
    366348         * Filters whether the REST API is enabled.
    367349         *
     
    429411         * header.
    430412         */
     413
    431414        if ( isset( $_GET['_method'] ) ) {
    432415            $request->set_method( $_GET['_method'] );
    433416        } elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) {
    434417            $request->set_method( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] );
     418
    435419        }
    436420
     
    490474         */
    491475        $served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this );
     476
     477
     478
     479
     480
     481
     482
     483
     484
     485
     486
     487
     488
     489
     490
     491
     492
     493
     494
     495
     496
     497
    492498
    493499        if ( ! $served ) {
  • branches/5.6/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

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

    r49193 r56882  
    161161
    162162/**
    163  * Search content for shortcodes and filter shortcodes through their hooks.
     163 * Returns a list of registered shortcode names found in the given content.
     164 *
     165 * Example usage:
     166 *
     167 *     get_shortcode_tags_in_content( '[audio src="file.mp3"][/audio] [foo] [gallery ids="1,2,3"]' );
     168 *     // array( 'audio', 'gallery' )
     169 *
     170 * @since 6.3.2
     171 *
     172 * @param string $content The content to check.
     173 * @return string[] An array of registered shortcode names found in the content.
     174 */
     175function get_shortcode_tags_in_content( $content ) {
     176    if ( false === strpos( $content, '[' ) ) {
     177        return array();
     178    }
     179
     180    preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER );
     181    if ( empty( $matches ) ) {
     182        return array();
     183    }
     184
     185    $tags = array();
     186    foreach ( $matches as $shortcode ) {
     187        $tags[] = $shortcode[2];
     188
     189        if ( ! empty( $shortcode[5] ) ) {
     190            $deep_tags = get_shortcode_tags_in_content( $shortcode[5] );
     191            if ( ! empty( $deep_tags ) ) {
     192                $tags = array_merge( $tags, $deep_tags );
     193            }
     194        }
     195    }
     196
     197    return $tags;
     198}
     199
     200/**
     201 * Searches content for shortcodes and filter shortcodes through their hooks.
    164202 *
    165203 * This function is an alias for do_shortcode().
Note: See TracChangeset for help on using the changeset viewer.