Skip to content

Commit 4ecb694

Browse files
committed
Grouped Backports to the 4.3 branch.
- Install: When populating options, maybe_serialize instead of always serialize. - Uploads: Check for and verify ZIP archives. Merges [57388] and [57389] to the 4.3 branch. Props costdev, peterwilsoncc, azaozz, tykoted, johnbillion, desrosj, afragen, jorbin, xknown. git-svn-id: https://develop.svn.wordpress.org/branches/4.3@57412 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 2feb551 commit 4ecb694

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

src/wp-admin/includes/class-wp-upgrader.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,6 +2431,30 @@ public function __construct( $form, $urlholder ) {
24312431
if ( isset( $file['error'] ) )
24322432
wp_die( $file['error'] );
24332433

2434+
if ( 'pluginzip' === $form || 'themezip' === $form ) {
2435+
$archive_is_valid = false;
2436+
2437+
/** This filter is documented in wp-admin/includes/file.php */
2438+
if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) {
2439+
$archive = new ZipArchive();
2440+
$archive_is_valid = $archive->open( $file['file'], ZIPARCHIVE::CHECKCONS );
2441+
2442+
if ( true === $archive_is_valid ) {
2443+
$archive->close();
2444+
}
2445+
} else {
2446+
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
2447+
2448+
$archive = new PclZip( $file['file'] );
2449+
$archive_is_valid = is_array( $archive->properties() );
2450+
}
2451+
2452+
if ( true !== $archive_is_valid ) {
2453+
wp_delete_file( $file['file'] );
2454+
wp_die( __( 'Incompatible Archive.' ) );
2455+
}
2456+
}
2457+
24342458
$this->filename = $_FILES[$form]['name'];
24352459
$this->package = $file['file'];
24362460

src/wp-admin/includes/schema.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,11 @@ function populate_options() {
529529
else
530530
$autoload = 'yes';
531531

532-
if ( is_array($value) )
533-
$value = serialize($value);
534532
if ( !empty($insert) )
535533
$insert .= ', ';
534+
535+
$value = maybe_serialize( sanitize_option( $option, $value ) );
536+
536537
$insert .= $wpdb->prepare( "(%s, %s, %s)", $option, $value, $autoload );
537538
}
538539

src/wp-admin/update.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@
129129

130130
check_admin_referer('plugin-upload');
131131

132+
if ( isset( $_FILES['pluginzip']['name'] ) && ! str_ends_with( strtolower( $_FILES['pluginzip']['name'] ), '.zip' ) ) {
133+
wp_die( __( 'Only .zip archives may be uploaded.' ) );
134+
}
135+
132136
$file_upload = new File_Upload_Upgrader('pluginzip', 'package');
133137

134138
$title = __('Upload Plugin');
@@ -234,6 +238,10 @@
234238

235239
check_admin_referer('theme-upload');
236240

241+
if ( isset( $_FILES['themezip']['name'] ) && ! str_ends_with( strtolower( $_FILES['themezip']['name'] ), '.zip' ) ) {
242+
wp_die( __( 'Only .zip archives may be uploaded.' ) );
243+
}
244+
237245
$file_upload = new File_Upload_Upgrader('themezip', 'package');
238246

239247
wp_enqueue_script( 'customize-loader' );

0 commit comments

Comments
 (0)