From 3fef086ede903f80487b7c0caba4d37ba3fb40c2 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Wed, 2 Nov 2016 06:28:29 +0000 Subject: [PATCH] REST API: Set default sanitize callback if type is set. Props joehoyle, ChopinBach, jnylen0. Fixes #38593. Built from https://develop.svn.wordpress.org/trunk@39091 git-svn-id: http://core.svn.wordpress.org/trunk@39033 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/rest-api/class-wp-rest-request.php | 5 +++++ wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api/class-wp-rest-request.php b/wp-includes/rest-api/class-wp-rest-request.php index 23156a31b0..d3e8c755af 100644 --- a/wp-includes/rest-api/class-wp-rest-request.php +++ b/wp-includes/rest-api/class-wp-rest-request.php @@ -804,6 +804,11 @@ class WP_REST_Request implements ArrayAccess { continue; } foreach ( $this->params[ $type ] as $key => $value ) { + // if no sanitize_callback was specified, default to rest_parse_request_arg + // if a type was specified in the args. + if ( ! isset( $attributes['args'][ $key ]['sanitize_callback'] ) && ! empty( $attributes['args'][ $key ]['type'] ) ) { + $attributes['args'][ $key ]['sanitize_callback'] = 'rest_parse_request_arg'; + } // Check if this param has a sanitize_callback added. if ( ! isset( $attributes['args'][ $key ] ) || empty( $attributes['args'][ $key ]['sanitize_callback'] ) ) { continue; diff --git a/wp-includes/version.php b/wp-includes/version.php index a1c841520f..ec36fca073 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-beta1-39090'; +$wp_version = '4.7-beta1-39091'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.