diff --git a/wp-admin/includes/class-file-upload-upgrader.php b/wp-admin/includes/class-file-upload-upgrader.php index 2b76e41ea6..e62561518d 100644 --- a/wp-admin/includes/class-file-upload-upgrader.php +++ b/wp-admin/includes/class-file-upload-upgrader.php @@ -69,6 +69,30 @@ class File_Upload_Upgrader { wp_die( $file['error'] ); } + if ( 'pluginzip' === $form || 'themezip' === $form ) { + $archive_is_valid = false; + + /** This filter is documented in wp-admin/includes/file.php */ + if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) { + $archive = new ZipArchive(); + $archive_is_valid = $archive->open( $file['file'], ZIPARCHIVE::CHECKCONS ); + + if ( true === $archive_is_valid ) { + $archive->close(); + } + } else { + require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; + + $archive = new PclZip( $file['file'] ); + $archive_is_valid = is_array( $archive->properties() ); + } + + if ( true !== $archive_is_valid ) { + wp_delete_file( $file['file'] ); + wp_die( __( 'Incompatible Archive.' ) ); + } + } + $this->filename = $_FILES[ $form ]['name']; $this->package = $file['file']; diff --git a/wp-admin/update.php b/wp-admin/update.php index 29480c2840..090c37cfc4 100644 --- a/wp-admin/update.php +++ b/wp-admin/update.php @@ -154,6 +154,10 @@ if ( isset( $_GET['action'] ) ) { check_admin_referer( 'plugin-upload' ); + if ( isset( $_FILES['pluginzip']['name'] ) && ! str_ends_with( strtolower( $_FILES['pluginzip']['name'] ), '.zip' ) ) { + wp_die( __( 'Only .zip archives may be uploaded.' ) ); + } + $file_upload = new File_Upload_Upgrader( 'pluginzip', 'package' ); // Used in the HTML title tag. @@ -302,6 +306,10 @@ if ( isset( $_GET['action'] ) ) { check_admin_referer( 'theme-upload' ); + if ( isset( $_FILES['themezip']['name'] ) && ! str_ends_with( strtolower( $_FILES['themezip']['name'] ), '.zip' ) ) { + wp_die( __( 'Only .zip archives may be uploaded.' ) ); + } + $file_upload = new File_Upload_Upgrader( 'themezip', 'package' ); // Used in the HTML title tag. diff --git a/wp-includes/version.php b/wp-includes/version.php index 354e16e629..528a2ec443 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5-alpha-57387'; +$wp_version = '6.5-alpha-57388'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.