Set the mb_string internal encoding to ISO-8859-1 whilst uncompressing archives using PclZip. Fixes 'PCLZIP_ERR_BAD_FORMAT (-10) : Invalid block size' errors on systems utilising mbstring.func_overload. Fixes #15789
git-svn-id: http://svn.automattic.com/wordpress/trunk@17592 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
65db854b9f
commit
9081c7636c
|
@ -652,12 +652,23 @@ function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
|
|||
function _unzip_file_pclzip($file, $to, $needed_dirs = array()) {
|
||||
global $wp_filesystem;
|
||||
|
||||
// See #15789 - PclZip uses string functions on binary data, If it's overloaded with Multibyte safe functions the results are incorrect.
|
||||
if ( ini_get('mbstring.func_overload') && function_exists('mb_internal_encoding') ) {
|
||||
$previous_encoding = mb_internal_encoding();
|
||||
mb_internal_encoding('ISO-8859-1');
|
||||
}
|
||||
|
||||
require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php');
|
||||
|
||||
$archive = new PclZip($file);
|
||||
|
||||
$archive_files = $archive->extract(PCLZIP_OPT_EXTRACT_AS_STRING);
|
||||
|
||||
if ( isset($previous_encoding) )
|
||||
mb_internal_encoding($previous_encoding);
|
||||
|
||||
// Is the archive valid?
|
||||
if ( false == ($archive_files = $archive->extract(PCLZIP_OPT_EXTRACT_AS_STRING)) )
|
||||
if ( false === $archive_files )
|
||||
return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true));
|
||||
|
||||
if ( 0 == count($archive_files) )
|
||||
|
|
Loading…
Reference in New Issue