From c985972791ffe4687ffc85cf878b6a8a38b45d51 Mon Sep 17 00:00:00 2001 From: audrasjb Date: Tue, 11 Oct 2022 13:25:11 +0000 Subject: [PATCH] Posts, Post Types: Ensure all entries in the list returned by `wp_parse_list()` are scalar. This changeset fixes a warning where `strip_tags()` expected its first parameter to be a string rather than an array. It contains the following changes: - Removal of sanitize_callback to allow the REST API to handle the validation natively, this also causes the proper error to be output for `?slug[0][1]=2` that it's an invalid value. - Ensure that `wp_parse_list()` only returns a single-dimensioned array, even if passed a multi-dimension array, which fits the functions expected use case and resolves warnings in code that expects the function to return a single-dimensioned array. Props dd32, TimothyBlynJacobs. Fixes #55838. Built from https://develop.svn.wordpress.org/trunk@54476 git-svn-id: http://core.svn.wordpress.org/trunk@54035 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 3 +++ .../rest-api/endpoints/class-wp-rest-posts-controller.php | 1 - wp-includes/version.php | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 77aaf718b1..56c36067bc 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -4821,6 +4821,9 @@ function wp_parse_list( $list ) { return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); } + // Validate all entries of the list are scalar. + $list = array_filter( $list, 'is_scalar' ); + return $list; } diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 2b543be296..deb83c2f03 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -2895,7 +2895,6 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { 'items' => array( 'type' => 'string', ), - 'sanitize_callback' => 'wp_parse_slug_list', ); $query_params['status'] = array( diff --git a/wp-includes/version.php b/wp-includes/version.php index 175ce5bcf7..890e995753 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-beta3-54475'; +$wp_version = '6.1-beta3-54476'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.