REST API: Prevent error when passing invalid `type` parameter to search endpoint.
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
This commit is contained in:
parent
65099c4373
commit
6e516fe3cc
|
@ -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.' ),
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue