Make WordPress Core

Changeset 57405


Ignore:
Timestamp:
01/30/2024 03:00:56 PM (10 months ago)
Author:
jorbin
Message:

Grouped Backports to the 5.0 branch.

  • Install: When populating options, maybe_serialize instead of always serialize.
  • Uploads: Check for and verify ZIP archives.

Merges [57388] and [57389] to the 5.0 branch.

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

Location:
branches/5.0
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0

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

    r41289 r57405  
    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'];
  • branches/5.0/src/wp-admin/includes/schema.php

    r43532 r57405  
    553553            $autoload = 'yes';
    554554
    555         if ( is_array($value) )
    556             $value = serialize($value);
    557555        if ( !empty($insert) )
    558556            $insert .= ', ';
     557
     558        $value = maybe_serialize( sanitize_option( $option, $value ) );
     559
    559560        $insert .= $wpdb->prepare( "(%s, %s, %s)", $option, $value, $autoload );
    560561    }
  • branches/5.0/src/wp-admin/update.php

    r41797 r57405  
    147147        check_admin_referer('plugin-upload');
    148148
     149        if ( isset( $_FILES['pluginzip']['name'] ) && ! str_ends_with( strtolower( $_FILES['pluginzip']['name'] ), '.zip' ) ) {
     150            wp_die( __( 'Only .zip archives may be uploaded.' ) );
     151        }
     152
    149153        $file_upload = new File_Upload_Upgrader('pluginzip', 'package');
    150154
     
    249253
    250254        check_admin_referer('theme-upload');
     255
     256        if ( isset( $_FILES['themezip']['name'] ) && ! str_ends_with( strtolower( $_FILES['themezip']['name'] ), '.zip' ) ) {
     257            wp_die( __( 'Only .zip archives may be uploaded.' ) );
     258        }
    251259
    252260        $file_upload = new File_Upload_Upgrader('themezip', 'package');
Note: See TracChangeset for help on using the changeset viewer.