Make WordPress Core


Ignore:
Timestamp:
01/30/2024 03:03:04 PM (14 months ago)
Author:
jorbin
Message:

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

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

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

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

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