Ticket #21292: 21292-2.diff
File 21292-2.diff, 3.9 KB (added by , 12 years ago) |
---|
-
wp-includes/functions.php
1586 1586 return array( 'error' => __( 'Empty filename' ) ); 1587 1587 1588 1588 $wp_filetype = wp_check_filetype( $name ); 1589 if ( !$wp_filetype['ext'])1589 if ( ( ! $wp_filetype['type'] || ! $wp_filetype['ext'] ) && ! current_user_can( 'unfiltered_upload' ) ) 1590 1590 return array( 'error' => __( 'Invalid file type' ) ); 1591 1591 1592 1592 $upload = wp_upload_dir( $time ); … … 1595 1595 return $upload; 1596 1596 1597 1597 $upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time ) ); 1598 if ( ! is_array( $upload_bits_error) ) {1598 if ( ! is_array( $upload_bits_error ) || isset( $upload_bits_error['error'] ) ) { 1599 1599 $upload[ 'error' ] = $upload_bits_error; 1600 1600 return $upload; 1601 1601 } … … 1617 1617 clearstatcache(); 1618 1618 1619 1619 // Set correct file permissions 1620 $stat = @stat( dirname( $new_file ) );1620 $stat = stat( dirname( $new_file ) ); 1621 1621 $perms = $stat['mode'] & 0007777; 1622 1622 $perms = $perms & 0000666; 1623 1623 @ chmod( $new_file, $perms ); … … 1626 1626 // Compute the URL 1627 1627 $url = $upload['url'] . "/$filename"; 1628 1628 1629 if ( is_multisite() ) 1630 delete_transient( 'dirsize_cache' ); 1631 1629 1632 return array( 'file' => $new_file, 'url' => $url, 'error' => false ); 1630 1633 } 1631 1634 -
wp-includes/class-wp-xmlrpc-server.php
4557 4557 } 4558 4558 4559 4559 $upload = wp_upload_bits($name, null, $bits); 4560 4560 4561 if ( ! empty($upload['error']) ) { 4561 4562 $errorString = sprintf(__('Could not write file %1$s (%2$s)'), $name, $upload['error']); 4562 4563 return new IXR_Error(500, $errorString); -
wp-admin/includes/ms.php
19 19 if ( get_site_option( 'upload_space_check_disabled' ) ) 20 20 return $file; 21 21 22 if ( $file['error'] != '0' ) // there's already an error22 if ( $file['error'] && $file['error'] != '0' ) // there's already an error 23 23 return $file; 24 24 25 25 if ( defined( 'WP_IMPORTING' ) ) … … 28 28 $space_allowed = 1048576 * get_space_allowed(); 29 29 $space_used = get_dirsize( BLOGUPLOADDIR ); 30 30 $space_left = $space_allowed - $space_used; 31 $file_size = filesize( $file['tmp_name'] ); 32 if ( $space_left < $file_size ) 31 32 if( 'wp_upload_bits' == current_filter() ) { 33 if( function_exists( 'mb_strlen' ) ) 34 $file_size = mb_strlen( $file['bits'], 'ascii'); 35 else 36 $file_size = strlen( $file['bits'] ); 37 } 38 else { 39 $file_size = filesize( $file['tmp_name'] ); 40 } 41 42 if( $space_left < $file_size ) 33 43 $file['error'] = sprintf( __( 'Not enough space to upload. %1$s KB needed.' ), number_format( ($file_size - $space_left) /1024 ) ); 34 if 44 if( $file_size > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) ) 35 45 $file['error'] = sprintf(__('This file is too big. Files must be less than %1$s KB in size.'), get_site_option( 'fileupload_maxk', 1500 ) ); 36 if 46 if( upload_is_user_over_quota( false ) ) { 37 47 $file['error'] = __( 'You have used your space quota. Please delete files before uploading.' ); 38 48 } 39 if ( $file['error'] != '0' && !isset($_POST['html-upload']) )49 if( $file['error'] != '0' && ! isset( $_POST['html-upload'] ) && 'wp_handle_upload_prefilter' == current_filter() ) 40 50 wp_die( $file['error'] . ' <a href="javascript:history.go(-1)">' . __( 'Back' ) . '</a>' ); 41 51 42 52 return $file; 43 53 } 44 54 add_filter( 'wp_handle_upload_prefilter', 'check_upload_size' ); 55 add_filter( 'wp_upload_bits', 'check_upload_size' ); 45 56 46 57 /** 47 58 * Delete a blog