From 8d6ec42ce1a5b90389f1ac46f19a5f62c455ead7 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 5 May 2009 05:57:56 +0000 Subject: [PATCH] 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 --- wp-admin/includes/media.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index bba0e2f1ac..217970bb0d 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -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