Make WordPress Core

Changeset 45267


Ignore:
Timestamp:
04/25/2019 12:07:23 AM (6 years ago)
Author:
kadamwhite
Message:

REST API: Always urlencode_deep() query args in get_items methods.

Passing all received query arguments through urlencode_deep ensures that the full set of query arguments are encoded in the same way.

Props dmsnell.
Fixes #46199

Location:
trunk/src/wp-includes/rest-api/endpoints
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

    r43987 r45267  
    286286        $response->header( 'X-WP-TotalPages', $max_pages );
    287287
    288         $base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
     288        $base = add_query_arg( urlencode_deep( $request->get_query_params() ), rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
    289289
    290290        if ( $request['page'] > 1 ) {
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r45190 r45267  
    344344
    345345        $request_params = $request->get_query_params();
    346         $base           = add_query_arg( $request_params, rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
     346        $base           = add_query_arg( urlencode_deep( $request_params ), rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
    347347
    348348        if ( $page > 1 ) {
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php

    r43584 r45267  
    302302
    303303        $request_params = $request->get_query_params();
    304         $base           = add_query_arg( $request_params, rest_url( sprintf( '%s/%s/%d/%s', $this->namespace, $this->parent_base, $request['parent'], $this->rest_base ) ) );
     304        $base           = add_query_arg( urlencode_deep( $request_params ), rest_url( sprintf( '%s/%s/%d/%s', $this->namespace, $this->parent_base, $request['parent'], $this->rest_base ) ) );
    305305
    306306        if ( $page > 1 ) {
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php

    r44107 r45267  
    156156
    157157        $request_params = $request->get_query_params();
    158         $base           = add_query_arg( $request_params, rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
     158        $base           = add_query_arg( urlencode_deep( $request_params ), rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
    159159
    160160        if ( $page > 1 ) {
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

    r44965 r45267  
    283283        $response->header( 'X-WP-TotalPages', (int) $max_pages );
    284284
    285         $base = add_query_arg( $request->get_query_params(), rest_url( $this->namespace . '/' . $this->rest_base ) );
     285        $base = add_query_arg( urlencode_deep( $request->get_query_params() ), rest_url( $this->namespace . '/' . $this->rest_base ) );
    286286        if ( $page > 1 ) {
    287287            $prev_page = $page - 1;
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

    r44641 r45267  
    330330        $response->header( 'X-WP-TotalPages', (int) $max_pages );
    331331
    332         $base = add_query_arg( $request->get_query_params(), rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
     332        $base = add_query_arg( urlencode_deep( $request->get_query_params() ), rest_url( sprintf( '%s/%s', $this->namespace, $this->rest_base ) ) );
    333333        if ( $page > 1 ) {
    334334            $prev_page = $page - 1;
Note: See TracChangeset for help on using the changeset viewer.