Make WordPress Core


Ignore:
Timestamp:
09/30/2025 05:05:21 PM (12 months ago)
Author:
desrosj
Message:

Grouped backports for the 5.2 branch.

  • REST API: Increase the specificity of capability checks for collections when the edit context is in use.
  • Menus: Prevent HTML in menu item titles from being rendered unexpectedly.

Merges [60814], [60815], [60816] to the 5.2 branch.

Props andraganescu, desrosj, ehti, hurayraiit, iandunn, joehoyle, johnbillion, jorbin, mnelson4, noisysocks, peterwilsoncc, phillsav, rmccue, timothyblynjacobs, vortfu, westonruter , whyisjake, zieladam.

Location:
branches/5.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.2

  • branches/5.2/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r50729 r60834  
    43144314
    43154315        /**
     4316         * @group 1018470
     4317         */
     4318        public function test_cannot_get_other_users_single_post_with_edit_context_if_disallowed() {
     4319                $author_post = self::factory()->post->create(
     4320                        array(
     4321                                'post_password' => 'test',
     4322                                'post_author'   => self::$author_id,
     4323                        )
     4324                );
     4325
     4326                wp_set_current_user( self::$contributor_id );
     4327
     4328                $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $author_post );
     4329                $request->set_query_params( array( 'context' => 'edit' ) );
     4330                $response = rest_do_request( $request );
     4331
     4332                $this->assertErrorResponse( 'rest_forbidden_context', $response, 403, 'Contributor should not be able to access Author post with edit context' );
     4333        }
     4334
     4335        /**
     4336         * @group 1018470
     4337         */
     4338        public function test_cannot_see_other_users_post_in_collection_with_edit_context_if_disallowed() {
     4339                $author_post = self::factory()->post->create(
     4340                        array(
     4341                                'post_password' => 'test',
     4342                                'post_author'   => self::$author_id,
     4343                        )
     4344                );
     4345
     4346                wp_set_current_user( self::$contributor_id );
     4347
     4348                $request = new WP_REST_Request( 'GET', '/wp/v2/posts' );
     4349                $request->set_query_params(
     4350                        array(
     4351                                'context' => 'edit',
     4352                                'include' => $author_post,
     4353                        )
     4354                );
     4355                $response = rest_do_request( $request );
     4356                $data     = $response->get_data();
     4357
     4358                $this->assertIsArray( $data );
     4359                $this->assertEmpty( $data );
     4360        }
     4361
     4362        /**
    43164363         * Internal function used to disable an insert query which
    43174364         * will trigger a wpdb error for testing purposes.
Note: See TracChangeset for help on using the changeset viewer.