Plugin Directory

Changeset 2617529


Ignore:
Timestamp:
10/21/2021 03:36:54 AM (4 years ago)
Author:
dtbaker
Message:

Uploading version 2.0.11

Location:
envato-elements/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • envato-elements/trunk/envato-elements.php

    r2614547 r2617529  
    55 * Author: Envato
    66 * Author URI: https://elements.envato.com/extensions/wordpress/?utm_source=extensions&utm_medium=referral&utm_campaign=elements_extensions_wpplugins
    7  * Version: 2.0.10
     7 * Version: 2.0.11
    88 * License: GPLv3 or later
    99 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    3131
    3232define( 'ENVATO_ELEMENTS_SLUG', 'envato-elements' );
    33 define( 'ENVATO_ELEMENTS_VER', '2.0.10' );
     33define( 'ENVATO_ELEMENTS_VER', '2.0.11' );
    3434define( 'ENVATO_ELEMENTS_FILE', __FILE__ );
    3535define( 'ENVATO_ELEMENTS_DIR', plugin_dir_path( ENVATO_ELEMENTS_FILE ) );
  • envato-elements/trunk/readme.txt

    r2614547 r2617529  
    55Tested up to: 5.8
    66Requires PHP: 5.6
    7 Stable tag: 2.0.10
     7Stable tag: 2.0.11
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    7979
    8080== Changelog ==
     81
     82= 2.0.11 - 2021-10-21 =
     83* Fix: Swap to using ZipArchive for Template Kit extraction
    8184
    8285= 2.0.10 - 2021-09-17 =
  • envato-elements/trunk/vendor/template-kit-import/inc/class-importer.php

    r2614547 r2617529  
    4343
    4444    /**
    45      * Called when we want to unpack a ZIP file into a folder.
    46      * Assumes the folder exists.
     45     * Extract
     46     *
     47     * Performs the extraction of the zip files to a temporary directory.
     48     * Returns an error if for some reason the ZipArchive utility isn't available.
     49     * Otherwise, Returns a strnig containing the temporary extraction directory
    4750     *
    4851     * @param string $temporary_zip_file
     
    5255     */
    5356    private function unpack_template_kit_zip_to_folder( $temporary_zip_file, $destination_folder ) {
    54         global $wp_filesystem;
    55 
    56         require_once ABSPATH . '/wp-admin/includes/file.php';
    57         \WP_Filesystem();
    58 
    59         if ( ! $wp_filesystem instanceof \WP_Filesystem_Base ) {
    60             return new \WP_Error( 'zip_error', 'Failed to initialize WP Filesystem' );
     57        if ( ! class_exists( '\ZipArchive' ) ) {
     58            return new \WP_Error( 'zip_error', 'PHP Zip extension not loaded' );
    6159        }
    6260
    63         $unzip_result = unzip_file( $temporary_zip_file, $destination_folder );
    64         if ( $unzip_result !== true ) {
    65             if ( is_wp_error( $unzip_result ) ) {
    66                 return $unzip_result;
     61        $allowed_file_types = [ 'json', 'jpg', 'png', 'css', 'html' ];
     62
     63        $zip = new \ZipArchive();
     64
     65        $zip->open( $temporary_zip_file );
     66
     67        $allowed_files = [];
     68
     69        // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
     70        for ( $i = 0; $i < $zip->numFiles; $i ++ ) {
     71            $filename  = $zip->getNameIndex( $i );
     72            $extension = pathinfo( $filename, PATHINFO_EXTENSION );
     73
     74            if ( in_array( $extension, $allowed_file_types, true ) ) {
     75                $allowed_files[] = $filename;
    6776            }
     77        }
    6878
    69             return new \WP_Error( 'zip_error', 'Failed to unzip zip file' );
    70         }
     79        $zip->extractTo( $destination_folder, $allowed_files );
     80
     81        $zip->close();
    7182
    7283        $extracted_zip_files = scandir( $destination_folder );
     
    7687            $file_names = array();
    7788        }
    78         if ( ! $file_names || ! in_array( 'manifest.json', $file_names, true ) || preg_grep( '/\.php/i', $file_names ) ) {
     89        if ( ! $file_names || ! in_array( 'manifest.json', $file_names, true ) ) {
    7990            $this->delete_template_kit_folder( $destination_folder );
    8091
Note: See TracChangeset for help on using the changeset viewer.