Make WordPress Core

Changeset 57399


Ignore:
Timestamp:
01/30/2024 02:50:35 PM (3 years ago)
Author:
jorbin
Message:

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

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

Location:
branches/5.6
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/5.6

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

    r47122 r57399  
    6969                        }
    7070
     71                        if ( 'pluginzip' === $form || 'themezip' === $form ) {
     72                                $archive_is_valid = false;
     73
     74                                /** This filter is documented in wp-admin/includes/file.php */
     75                                if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) {
     76                                        $archive          = new ZipArchive();
     77                                        $archive_is_valid = $archive->open( $file['file'], ZIPARCHIVE::CHECKCONS );
     78
     79                                        if ( true === $archive_is_valid ) {
     80                                                $archive->close();
     81                                        }
     82                                } else {
     83                                        require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
     84
     85                                        $archive          = new PclZip( $file['file'] );
     86                                        $archive_is_valid = is_array( $archive->properties() );
     87                                }
     88
     89                                if ( true !== $archive_is_valid ) {
     90                                        wp_delete_file( $file['file'] );
     91                                        wp_die( __( 'Incompatible Archive.' ) );
     92                                }
     93                        }
     94
    7195                        $this->filename = $_FILES[ $form ]['name'];
    7296                        $this->package  = $file['file'];
  • branches/5.6/src/wp-admin/includes/schema.php

    r49581 r57399  
    585585                }
    586586
    587                 if ( is_array( $value ) ) {
    588                         $value = serialize( $value );
    589                 }
    590 
    591587                if ( ! empty( $insert ) ) {
    592588                        $insert .= ', ';
    593589                }
     590
     591                $value = maybe_serialize( sanitize_option( $option, $value ) );
    594592
    595593                $insert .= $wpdb->prepare( '(%s, %s, %s)', $option, $value, $autoload );
  • branches/5.6/src/wp-admin/update.php

    r48417 r57399  
    151151
    152152                check_admin_referer( 'plugin-upload' );
     153
     154                if ( isset( $_FILES['pluginzip']['name'] ) && ! str_ends_with( strtolower( $_FILES['pluginzip']['name'] ), '.zip' ) ) {
     155                        wp_die( __( 'Only .zip archives may be uploaded.' ) );
     156                }
    153157
    154158                $file_upload = new File_Upload_Upgrader( 'pluginzip', 'package' );
     
    293297
    294298                check_admin_referer( 'theme-upload' );
     299
     300                if ( isset( $_FILES['themezip']['name'] ) && ! str_ends_with( strtolower( $_FILES['themezip']['name'] ), '.zip' ) ) {
     301                        wp_die( __( 'Only .zip archives may be uploaded.' ) );
     302                }
    295303
    296304                $file_upload = new File_Upload_Upgrader( 'themezip', 'package' );
Note: See TracChangeset for help on using the changeset viewer.