From c9301a30be6a7f4ceabf99a9330f4e7ad86c0d84 Mon Sep 17 00:00:00 2001 From: nacin Date: Mon, 12 Sep 2011 21:48:44 +0000 Subject: [PATCH] Loosen validation regex to use sanitize_key() in a few AJAX locations for things like pages, orders, columns. Change return value to 0 for failure, as -1 is reserved for authentication/intention. props ocean90, azaozz, fixes #18637. git-svn-id: http://svn.automattic.com/wordpress/trunk@18663 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-ajax.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 9ca6dec76b..a22751a021 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -1025,8 +1025,8 @@ case 'closed-postboxes' : $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; - if ( !preg_match( '/^[a-z_-]+$/', $page ) ) - die('-1'); + if ( $page != sanitize_key( $page ) ) + die('0'); if ( ! $user = wp_get_current_user() ) die('-1'); @@ -1047,8 +1047,8 @@ case 'hidden-columns' : $hidden = explode( ',', $_POST['hidden'] ); $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; - if ( !preg_match( '/^[a-z_-]+$/', $page ) ) - die('-1'); + if ( $page != sanitize_key( $page ) ) + die('0'); if ( ! $user = wp_get_current_user() ) die('-1'); @@ -1146,8 +1146,8 @@ case 'meta-box-order': $page = isset( $_POST['page'] ) ? $_POST['page'] : ''; - if ( !preg_match( '/^[a-z_-]+$/', $page ) ) - die('-1'); + if ( $page != sanitize_key( $page ) ) + die('0'); if ( ! $user = wp_get_current_user() ) die('-1');