WordPress.org

Make WordPress Core

Changeset 25349


Ignore:
Timestamp:
09/11/2013 08:26:57 AM (7 years ago)
Author:
dd32
Message:

Make use of the mbstring.func_overload helper functions in WP_Filesystem so byte lengths are properly determined. See #25259 Fixes #25237

Location:
trunk/src/wp-admin/includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-filesystem-direct.php

    r25305 r25349  
    6969            return false;
    7070
     71        mbstring_binary_safe_encoding();
     72
     73        $data_length = strlen( $contents );
     74
    7175        $bytes_written = fwrite( $fp, $contents );
    7276
     77        reset_mbstring_encoding();
     78
    7379        fclose( $fp );
    7480
    75         if ( false === $bytes_written || $bytes_written != strlen( $contents ) )
     81        if ( $data_length !== $bytes_written )
    7682            return false;
    7783
  • trunk/src/wp-admin/includes/class-wp-filesystem-ftpext.php

    r25305 r25349  
    119119            return false;
    120120
     121        mbstring_binary_safe_encoding();
     122
     123        $data_length = strlen( $contents );
    121124        $bytes_written = fwrite( $temp, $contents );
    122         if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) {
     125
     126        reset_mbstring_encoding();
     127
     128        if ( $data_length !== $bytes_written ) {
    123129            fclose( $temp );
    124130            unlink( $tempfile );
  • trunk/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php

    r25305 r25349  
    9090            return false;
    9191
     92        mbstring_binary_safe_encoding();
     93
    9294        if ( ! $this->ftp->fget($temphandle, $file) ) {
    9395            fclose($temphandle);
    9496            unlink($temp);
     97
     98            reset_mbstring_encoding();
     99
    95100            return ''; // Blank document, File does exist, It's just blank.
    96101        }
     102
     103        reset_mbstring_encoding();
    97104
    98105        fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
     
    118125        }
    119126
     127        // The FTP class uses string functions internally during file download/upload
     128        mbstring_binary_safe_encoding();
     129
    120130        $bytes_written = fwrite( $temphandle, $contents );
    121131        if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) {
    122132            fclose( $temphandle );
    123133            unlink( $temp );
     134
     135            reset_mbstring_encoding();
     136
    124137            return false;
    125138        }
     
    128141
    129142        $ret = $this->ftp->fput($file, $temphandle);
     143
     144        reset_mbstring_encoding();
    130145
    131146        fclose($temphandle);
     
    294309        }
    295310
     311        mbstring_binary_safe_encoding();
     312
    296313        $list = $this->ftp->dirlist($path);
    297         if ( empty($list) && !$this->exists($path) )
    298             return false;
     314        if ( empty( $list ) && ! $this->exists( $path ) ) {
     315
     316            reset_mbstring_encoding();
     317
     318            return false;
     319        }
    299320
    300321        $ret = array();
     
    323344            $ret[ $struc['name'] ] = $struc;
    324345        }
     346
     347        reset_mbstring_encoding();
     348
    325349        return $ret;
    326350    }
Note: See TracChangeset for help on using the changeset viewer.