Don't over sanitize uploaded file titles. Props hakre. fixes #9081

git-svn-id: http://svn.automattic.com/wordpress/trunk@11198 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-05-05 05:57:56 +00:00
parent cc3d87bf2b
commit 8d6ec42ce1
1 changed files with 5 additions and 1 deletions

View File

@ -189,15 +189,19 @@ function media_handle_upload($file_id, $post_id, $post_data = array()) {
$time = $post->post_date;
}
$name = $_FILES[$file_id]['name'];
$file = wp_handle_upload($_FILES[$file_id], $overrides, $time);
if ( isset($file['error']) )
return new WP_Error( 'upload_error', $file['error'] );
$name_parts = pathinfo($name);
$name = trim( substr( $name, 0, -(1 + strlen($name_parts['extension'])) ) );
$url = $file['url'];
$type = $file['type'];
$file = $file['file'];
$title = preg_replace('/\.[^.]+$/', '', basename($file));
$title = $name;
$content = '';
// use image exif/iptc data for title and caption defaults if possible