Changeset 12165 for trunk/wp-includes/formatting.php
- Timestamp:
- 11/11/2009 11:07:29 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/formatting.php
r12088 r12165 652 652 $filename = preg_replace('/[\s-]+/', '-', $filename); 653 653 $filename = trim($filename, '.-_'); 654 655 // Split the filename into a base and extension[s] 656 $parts = explode('.', $filename); 657 658 // Return if only one extension 659 if ( count($parts) <= 2 ) 660 return apply_filters('sanitize_file_name', $filename, $filename_raw); 661 662 // Process multiple extensions 663 $filename = array_shift($parts); 664 $extension = array_pop($parts); 665 $mimes = get_allowed_mime_types(); 666 667 // Loop over any intermediate extensions. Munge them with a trailing underscore if they are a 2 - 5 character 668 // long alpha string not in the extension whitelist. 669 foreach ( (array) $parts as $part) { 670 $filename .= '.' . $part; 671 672 if ( preg_match("/^[a-zA-Z]{2,5}\d?$/", $part) ) { 673 $allowed = false; 674 foreach ( $mimes as $ext_preg => $mime_match ) { 675 $ext_preg = '!(^' . $ext_preg . ')$!i'; 676 if ( preg_match( $ext_preg, $part ) ) { 677 $allowed = true; 678 break; 679 } 680 } 681 if ( !$allowed ) 682 $filename .= '_'; 683 } 684 } 685 $filename .= '.' . $extension; 686 654 687 return apply_filters('sanitize_file_name', $filename, $filename_raw); 655 688 }
Note: See TracChangeset
for help on using the changeset viewer.