mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-08 16:41:44 +01:00
Filesystem API: Ensure filenames are valid before attempting to unzip them to ensure malformed file paths don't cause issues.
Built from https://develop.svn.wordpress.org/trunk@41457 git-svn-id: http://core.svn.wordpress.org/trunk@41290 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1115a36cda
commit
69de73224f
@ -666,6 +666,10 @@ 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;
|
||||||
|
|
||||||
|
if ( 0 !== validate_file( $info['name'] ) ) {
|
||||||
|
return new WP_Error( 'invalid_file_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
|
||||||
|
}
|
||||||
|
|
||||||
$uncompressed_size += $info['size'];
|
$uncompressed_size += $info['size'];
|
||||||
|
|
||||||
if ( '/' === substr( $info['name'], -1 ) ) {
|
if ( '/' === substr( $info['name'], -1 ) ) {
|
||||||
@ -826,6 +830,10 @@ 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;
|
||||||
|
|
||||||
|
if ( 0 !== validate_file( $file['filename'] ) ) {
|
||||||
|
return new WP_Error( 'invalid_file_pclzip', __( 'Could not extract file from archive.' ), $file['filename'] );
|
||||||
|
}
|
||||||
|
|
||||||
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) )
|
||||||
return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] );
|
return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] );
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.9-alpha-41448';
|
$wp_version = '4.9-alpha-41457';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user