WordPress.org

Make WordPress Core

Changeset 14349


Ignore:
Timestamp:
05/02/10 23:24:36 (4 years ago)
Author:
dd32
Message:

Skip over MACOSX folders during zip extraction. Props chrisbliss18. Fixes #12637

File:
1 edited

Legend:

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

    r14346 r14349  
    504504/** 
    505505 * Unzip's a specified ZIP file to a location on the Filesystem via the WordPress Filesystem Abstraction. 
    506  * Assumes that WP_Filesystem() has already been called and set up. 
     506 * Assumes that WP_Filesystem() has already been called and set up. Does not extract a root-level __MACOSX directory, if present. 
    507507 * 
    508508 * Attempts to increase the PHP Memory limit to 256M before uncompressing, 
     
    585585            return new WP_Error('stat_failed', __('Could not retrieve file from archive.')); 
    586586 
     587        if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory 
     588            continue; 
     589 
    587590        if ( '/' == substr($info['name'], -1) ) // directory 
    588591            $needed_dirs[] = $to . untrailingslashit($info['name']); 
     
    608611            continue; 
    609612 
     613        if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files 
     614            continue;  
     615 
    610616        $contents = $z->getFromIndex($i); 
    611617        if ( false === $contents ) 
     
    649655 
    650656    // Determine any children directories needed (From within the archive) 
    651     foreach ( $archive_files as $file ) 
     657    foreach ( $archive_files as $file ) { 
     658        if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Skip the OS X-created __MACOSX directory  
     659            continue; 
     660     
    652661        $needed_dirs[] = $to . untrailingslashit( $file['folder'] ? $file['filename'] : dirname($file['filename']) ); 
     662    } 
    653663 
    654664    $needed_dirs = array_unique($needed_dirs); 
     
    665675    foreach ( $archive_files as $file ) { 
    666676        if ( $file['folder'] ) 
     677            continue; 
     678 
     679        if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files 
    667680            continue; 
    668681 
Note: See TracChangeset for help on using the changeset viewer.