Make use of the mbstring.func_overload helper functions in WP_Filesystem so byte lengths are properly determined. See #25259 Fixes #25237
Built from https://develop.svn.wordpress.org/trunk@25349 git-svn-id: http://core.svn.wordpress.org/trunk@25311 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c93eb27bb2
commit
26ebfca466
|
@ -68,11 +68,17 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
|||
if ( ! $fp )
|
||||
return false;
|
||||
|
||||
mbstring_binary_safe_encoding();
|
||||
|
||||
$data_length = strlen( $contents );
|
||||
|
||||
$bytes_written = fwrite( $fp, $contents );
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
||||
fclose( $fp );
|
||||
|
||||
if ( false === $bytes_written || $bytes_written != strlen( $contents ) )
|
||||
if ( $data_length !== $bytes_written )
|
||||
return false;
|
||||
|
||||
$this->chmod( $file, $mode );
|
||||
|
|
|
@ -118,8 +118,14 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
|||
if ( ! $temp )
|
||||
return false;
|
||||
|
||||
mbstring_binary_safe_encoding();
|
||||
|
||||
$data_length = strlen( $contents );
|
||||
$bytes_written = fwrite( $temp, $contents );
|
||||
if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) {
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
||||
if ( $data_length !== $bytes_written ) {
|
||||
fclose( $temp );
|
||||
unlink( $tempfile );
|
||||
return false;
|
||||
|
|
|
@ -89,12 +89,19 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
if ( ! $temphandle = fopen($temp, 'w+') )
|
||||
return false;
|
||||
|
||||
mbstring_binary_safe_encoding();
|
||||
|
||||
if ( ! $this->ftp->fget($temphandle, $file) ) {
|
||||
fclose($temphandle);
|
||||
unlink($temp);
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
||||
return ''; // Blank document, File does exist, It's just blank.
|
||||
}
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
||||
fseek( $temphandle, 0 ); // Skip back to the start of the file being written to
|
||||
$contents = '';
|
||||
|
||||
|
@ -117,10 +124,16 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
return false;
|
||||
}
|
||||
|
||||
// The FTP class uses string functions internally during file download/upload
|
||||
mbstring_binary_safe_encoding();
|
||||
|
||||
$bytes_written = fwrite( $temphandle, $contents );
|
||||
if ( false === $bytes_written || $bytes_written != strlen( $contents ) ) {
|
||||
fclose( $temphandle );
|
||||
unlink( $temp );
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -128,6 +141,8 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
|
||||
$ret = $this->ftp->fput($file, $temphandle);
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
||||
fclose($temphandle);
|
||||
unlink($temp);
|
||||
|
||||
|
@ -293,9 +308,15 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
$limit_file = false;
|
||||
}
|
||||
|
||||
mbstring_binary_safe_encoding();
|
||||
|
||||
$list = $this->ftp->dirlist($path);
|
||||
if ( empty($list) && !$this->exists($path) )
|
||||
if ( empty( $list ) && ! $this->exists( $path ) ) {
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
foreach ( $list as $struc ) {
|
||||
|
@ -322,6 +343,9 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
|||
|
||||
$ret[ $struc['name'] ] = $struc;
|
||||
}
|
||||
|
||||
reset_mbstring_encoding();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue