WordPress.org

Make WordPress Core

Changeset 7440


Ignore:
Timestamp:
03/21/08 04:03:33 (7 years ago)
Author:
markjaquith
Message:

Prevent uploads from overwriting each other. props neodude. fixes #6294

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r7438 r7440  
    11231123    $ext = $info['extension']; 
    11241124    $name = basename($filename, ".{$ext}"); 
     1125     
     1126    // edge case: if file is named '.ext', treat as an empty name 
     1127    if( $name === ".$ext" ) 
     1128        $name = ''; 
    11251129 
    11261130    // Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied. 
     
    11291133    } else { 
    11301134        $number = ''; 
    1131         $filename = str_replace( '#', '_', $name ); 
    1132         $filename = str_replace( array( '\\', "'" ), '', $filename ); 
    1133         if ( empty( $ext) ) 
     1135 
     1136        if ( empty( $ext ) ) 
    11341137            $ext = ''; 
    11351138        else 
    11361139            $ext = strtolower( ".$ext" ); 
    1137         $filename = $filename . $ext; 
     1140 
     1141        $filename = str_replace( $ext, '', $filename ); 
     1142        $filename = sanitize_title_with_dashes( $filename ) . $ext; 
     1143 
    11381144        while ( file_exists( $dir . "/$filename" ) ) { 
    11391145            if ( '' == "$number$ext" ) 
     
    11421148                $filename = str_replace( "$number$ext", ++$number . $ext, $filename ); 
    11431149        } 
    1144         $filename = str_replace( $ext, '', $filename ); 
    1145         $filename = sanitize_title_with_dashes( $filename ) . $ext; 
    11461150    } 
    11471151 
Note: See TracChangeset for help on using the changeset viewer.