Filesystem API: Don't immediately return an error for invalid file names contained within a Zip while it's being extracted.
This allows the extraction of the rest of the valid files within the archive to continue. See #42016 git-svn-id: https://develop.svn.wordpress.org/trunk@42010 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
18a231bad6
commit
49b7cb458f
@ -1119,8 +1119,9 @@ function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
|
|||||||
if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory
|
if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Skip the OS X-created __MACOSX directory
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Don't extract invalid files:
|
||||||
if ( 0 !== validate_file( $info['name'] ) ) {
|
if ( 0 !== validate_file( $info['name'] ) ) {
|
||||||
return new WP_Error( 'invalid_file_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uncompressed_size += $info['size'];
|
$uncompressed_size += $info['size'];
|
||||||
@ -1180,6 +1181,11 @@ function _unzip_file_ziparchive($file, $to, $needed_dirs = array() ) {
|
|||||||
if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
|
if ( '__MACOSX/' === substr($info['name'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Don't extract invalid files:
|
||||||
|
if ( 0 !== validate_file( $info['name'] ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$contents = $z->getFromIndex($i);
|
$contents = $z->getFromIndex($i);
|
||||||
if ( false === $contents )
|
if ( false === $contents )
|
||||||
return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
|
return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
|
||||||
@ -1283,8 +1289,9 @@ function _unzip_file_pclzip($file, $to, $needed_dirs = array()) {
|
|||||||
if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
|
if ( '__MACOSX/' === substr($file['filename'], 0, 9) ) // Don't extract the OS X-created __MACOSX directory files
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Don't extract invalid files:
|
||||||
if ( 0 !== validate_file( $file['filename'] ) ) {
|
if ( 0 !== validate_file( $file['filename'] ) ) {
|
||||||
return new WP_Error( 'invalid_file_pclzip', __( 'Could not extract file from archive.' ), $file['filename'] );
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
|
if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE) )
|
||||||
|
Loading…
Reference in New Issue
Block a user