Changeset 12166 for branches/2.8/wp-includes/formatting.php
- Timestamp:
- 11/11/2009 11:10:13 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.8/wp-includes/formatting.php
r12073 r12166 606 606 $filename = preg_replace('/[\s-]+/', '-', $filename); 607 607 $filename = trim($filename, '.-_'); 608 609 // Split the filename into a base and extension[s] 610 $parts = explode('.', $filename); 611 612 // Return if only one extension 613 if ( count($parts) <= 2 ) 614 return apply_filters('sanitize_file_name', $filename, $filename_raw); 615 616 // Process multiple extensions 617 $filename = array_shift($parts); 618 $extension = array_pop($parts); 619 $mimes = get_allowed_mime_types(); 620 621 // Loop over any intermediate extensions. Munge them with a trailing underscore if they are a 2 - 5 character 622 // long alpha string not in the extension whitelist. 623 foreach ( (array) $parts as $part) { 624 $filename .= '.' . $part; 625 626 if ( preg_match("/^[a-zA-Z]{2,5}\d?$/", $part) ) { 627 $allowed = false; 628 foreach ( $mimes as $ext_preg => $mime_match ) { 629 $ext_preg = '!(^' . $ext_preg . ')$!i'; 630 if ( preg_match( $ext_preg, $part ) ) { 631 $allowed = true; 632 break; 633 } 634 } 635 if ( !$allowed ) 636 $filename .= '_'; 637 } 638 } 639 $filename .= '.' . $extension; 640 608 641 return apply_filters('sanitize_file_name', $filename, $filename_raw); 609 642 }
Note: See TracChangeset
for help on using the changeset viewer.