WordPress.org

Make WordPress Core

Ticket #9081: 9081.3.patch

File 9081.3.patch, 817 bytes (added by hakre, 9 years ago)

A trim does not hurt.

  • wp-admin/includes/media.php

     
    189189                        $time = $post->post_date;
    190190        }
    191191
     192        $name = $_FILES[$file_id]['name'];
    192193        $file = wp_handle_upload($_FILES[$file_id], $overrides, $time);
    193194
    194195        if ( isset($file['error']) )
    195196                return new WP_Error( 'upload_error', $file['error'] );
     197               
     198        $name_parts = pathinfo($name);
     199        $name = trim( substr( $name, 0, -(1 + strlen($name_parts['extension'])) ) );
    196200
    197201        $url = $file['url'];
    198202        $type = $file['type'];
    199203        $file = $file['file'];
    200         $title = preg_replace('/\.[^.]+$/', '', basename($file));
     204        $title = $name;
    201205        $content = '';
    202206
    203207        // use image exif/iptc data for title and caption defaults if possible