Simplify sanitize_key() and use it in more places. see #14910
git-svn-id: http://svn.automattic.com/wordpress/trunk@15635 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c2100074d3
commit
6b351163ef
|
@ -763,10 +763,6 @@ function sanitize_user( $username, $strict = false ) {
|
||||||
*/
|
*/
|
||||||
function sanitize_key( $key ) {
|
function sanitize_key( $key ) {
|
||||||
$raw_key = $key;
|
$raw_key = $key;
|
||||||
$key = wp_strip_all_tags($key);
|
|
||||||
// Kill octets
|
|
||||||
$key = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $key);
|
|
||||||
$key = preg_replace('/&.+?;/', '', $key); // Kill entities
|
|
||||||
|
|
||||||
$key = preg_replace('|[^a-z0-9 _.\-@]|i', '', $key);
|
$key = preg_replace('|[^a-z0-9 _.\-@]|i', '', $key);
|
||||||
|
|
||||||
|
|
|
@ -571,7 +571,7 @@ function register_post_status($post_status, $args = array()) {
|
||||||
$args = wp_parse_args($args, $defaults);
|
$args = wp_parse_args($args, $defaults);
|
||||||
$args = (object) $args;
|
$args = (object) $args;
|
||||||
|
|
||||||
$post_status = sanitize_user($post_status, true);
|
$post_status = sanitize_key($post_status);
|
||||||
$args->name = $post_status;
|
$args->name = $post_status;
|
||||||
|
|
||||||
if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private )
|
if ( null === $args->public && null === $args->internal && null === $args->protected && null === $args->private )
|
||||||
|
@ -819,7 +819,7 @@ function register_post_type($post_type, $args = array()) {
|
||||||
$args = wp_parse_args($args, $defaults);
|
$args = wp_parse_args($args, $defaults);
|
||||||
$args = (object) $args;
|
$args = (object) $args;
|
||||||
|
|
||||||
$post_type = sanitize_user($post_type, true);
|
$post_type = sanitize_key($post_type);
|
||||||
$args->name = $post_type;
|
$args->name = $post_type;
|
||||||
|
|
||||||
// If not set, default to the setting for public.
|
// If not set, default to the setting for public.
|
||||||
|
|
|
@ -1456,9 +1456,9 @@ class WP_Query {
|
||||||
|
|
||||||
if ( !empty($qv['post_type']) ) {
|
if ( !empty($qv['post_type']) ) {
|
||||||
if ( is_array($qv['post_type']) )
|
if ( is_array($qv['post_type']) )
|
||||||
$qv['post_type'] = array_map('sanitize_user', $qv['post_type'], array(true));
|
$qv['post_type'] = array_map('sanitize_key', $qv['post_type']);
|
||||||
else
|
else
|
||||||
$qv['post_type'] = sanitize_user($qv['post_type'], true);
|
$qv['post_type'] = sanitize_key($qv['post_type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty($qv['post_status']) )
|
if ( !empty($qv['post_status']) )
|
||||||
|
|
Loading…
Reference in New Issue