REST API: Exclude numeric parameters from regex parsing

The list of endpoint parameters should only include explicitly named and requested parameters.

Props flixos90, rmccue, jnylen0.
Fixes #40704.

Built from https://develop.svn.wordpress.org/trunk@41223


git-svn-id: http://core.svn.wordpress.org/trunk@41063 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
James Nylen 2017-08-03 19:55:43 +00:00
parent 17c48865db
commit 0ef4d4289f
2 changed files with 9 additions and 2 deletions

View File

@ -824,12 +824,19 @@ class WP_REST_Server {
$path = $request->get_route();
foreach ( $this->get_routes() as $route => $handlers ) {
$match = preg_match( '@^' . $route . '$@i', $path, $args );
$match = preg_match( '@^' . $route . '$@i', $path, $matches );
if ( ! $match ) {
continue;
}
$args = array();
foreach ( $matches as $param => $value ) {
if ( ! is_int( $param ) ) {
$args[ $param ] = $value;
}
}
foreach ( $handlers as $handler ) {
$callback = $handler['callback'];
$response = null;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-alpha-41222';
$wp_version = '4.9-alpha-41223';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.