Make WordPress Core


Ignore:
Timestamp:
01/30/2024 03:06:32 PM (8 months ago)
Author:
jorbin
Message:

Grouped Backports to the 4.7 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.7 branch.

Props costdev, peterwilsoncc, azaozz, tykoted, johnbillion, desrosj, afragen, jorbin, xknown.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-admin/includes/class-file-upload-upgrader.php

    r38524 r57408  
    6868                wp_die( $file['error'] );
    6969
     70            if ( 'pluginzip' === $form || 'themezip' === $form ) {
     71                $archive_is_valid = false;
     72
     73                /** This filter is documented in wp-admin/includes/file.php */
     74                if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) {
     75                    $archive          = new ZipArchive();
     76                    $archive_is_valid = $archive->open( $file['file'], ZIPARCHIVE::CHECKCONS );
     77
     78                    if ( true === $archive_is_valid ) {
     79                        $archive->close();
     80                    }
     81                } else {
     82                    require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
     83
     84                    $archive          = new PclZip( $file['file'] );
     85                    $archive_is_valid = is_array( $archive->properties() );
     86                }
     87
     88                if ( true !== $archive_is_valid ) {
     89                    wp_delete_file( $file['file'] );
     90                    wp_die( __( 'Incompatible Archive.' ) );
     91                }
     92            }
     93
    7094            $this->filename = $_FILES[$form]['name'];
    7195            $this->package = $file['file'];
Note: See TracChangeset for help on using the changeset viewer.