sanitize_file_name(). fixes #3382 #3554

git-svn-id: http://svn.automattic.com/wordpress/trunk@4710 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-01-09 22:53:14 +00:00
parent 9154236572
commit 3a87e7bba0
2 changed files with 13 additions and 2 deletions

View File

@ -288,6 +288,17 @@ function remove_accents($string) {
return $string;
}
function sanitize_file_name( $name ) { // Like sanitize_title, but with periods
$name = strtolower( $name );
$name = preg_replace('/&.+?;/', '', $name); // kill entities
$name = str_replace( '_', '-', $name );
$name = preg_replace('/[^a-z0-9\s-.]/', '', $name);
$name = preg_replace('/\s+/', '-', $name);
$name = preg_replace('|-+|', '-', $name);
$name = trim($name, '-');
return $name;
}
function sanitize_user( $username, $strict = false ) {
$raw_username = $username;
$username = strip_tags($username);

View File

@ -836,7 +836,7 @@ class wp_xmlrpc_server extends IXR_Server {
$user_pass = $wpdb->escape($args[2]);
$data = $args[3];
$name = sanitize_file( $data['name'] );
$name = sanitize_file_name( $data['name'] );
$type = $data['type'];
$bits = $data['bits'];