From 6e516fe3cc2505a1a3ba780a04126569f849041a Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 15 Mar 2024 11:25:06 +0000 Subject: [PATCH] REST API: Prevent error when passing invalid `type` parameter to search endpoint. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In `WP_REST_Search_Controller`, the `type` parameter is accessed via the sanitization callback for the `subtype` parameter, which is too early for `type` itself to be already sanitized. This change adds a type check in the `get_search_handler()` method to prevent errors when the type doesn’t match. Props swissspidy, timothyblynjacobs, dd32. Fixes #60771. Built from https://develop.svn.wordpress.org/trunk@57839 git-svn-id: http://core.svn.wordpress.org/trunk@57340 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../rest-api/endpoints/class-wp-rest-search-controller.php | 2 +- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php index cc1c302b9c..55fe1ad63a 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php @@ -395,7 +395,7 @@ class WP_REST_Search_Controller extends WP_REST_Controller { protected function get_search_handler( $request ) { $type = $request->get_param( self::PROP_TYPE ); - if ( ! $type || ! isset( $this->search_handlers[ $type ] ) ) { + if ( ! $type || ! is_string( $type ) || ! isset( $this->search_handlers[ $type ] ) ) { return new WP_Error( 'rest_search_invalid_type', __( 'Invalid type parameter.' ), diff --git a/wp-includes/version.php b/wp-includes/version.php index 8e0e62e1c4..206923364c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-alpha-57836'; +$wp_version = '6.6-alpha-57839'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.