Make WordPress Core

Changeset 17592


Ignore:
Timestamp:
04/03/2011 12:32:06 PM (14 years ago)
Author:
dd32
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/file.php

    r17576 r17592  
    653653    global $wp_filesystem;
    654654
     655    // See #15789 - PclZip uses string functions on binary data, If it's overloaded with Multibyte safe functions the results are incorrect.
     656    if ( ini_get('mbstring.func_overload') && function_exists('mb_internal_encoding') ) {
     657        $previous_encoding = mb_internal_encoding();
     658        mb_internal_encoding('ISO-8859-1');
     659    }
     660
    655661    require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php');
    656662
    657663    $archive = new PclZip($file);
    658664
     665    $archive_files = $archive->extract(PCLZIP_OPT_EXTRACT_AS_STRING);
     666
     667    if ( isset($previous_encoding) )
     668        mb_internal_encoding($previous_encoding);
     669
    659670    // Is the archive valid?
    660     if ( false == ($archive_files = $archive->extract(PCLZIP_OPT_EXTRACT_AS_STRING)) )
     671    if ( false === $archive_files )
    661672        return new WP_Error('incompatible_archive', __('Incompatible Archive.'), $archive->errorInfo(true));
    662673
Note: See TracChangeset for help on using the changeset viewer.