Changeset 2617529
- Timestamp:
- 10/21/2021 03:36:54 AM (4 years ago)
- Location:
- envato-elements/trunk
- Files:
-
- 3 edited
-
envato-elements.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
vendor/template-kit-import/inc/class-importer.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
envato-elements/trunk/envato-elements.php
r2614547 r2617529 5 5 * Author: Envato 6 6 * Author URI: https://elements.envato.com/extensions/wordpress/?utm_source=extensions&utm_medium=referral&utm_campaign=elements_extensions_wpplugins 7 * Version: 2.0.1 07 * Version: 2.0.11 8 8 * License: GPLv3 or later 9 9 * License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 31 31 32 32 define( 'ENVATO_ELEMENTS_SLUG', 'envato-elements' ); 33 define( 'ENVATO_ELEMENTS_VER', '2.0.1 0' );33 define( 'ENVATO_ELEMENTS_VER', '2.0.11' ); 34 34 define( 'ENVATO_ELEMENTS_FILE', __FILE__ ); 35 35 define( 'ENVATO_ELEMENTS_DIR', plugin_dir_path( ENVATO_ELEMENTS_FILE ) ); -
envato-elements/trunk/readme.txt
r2614547 r2617529 5 5 Tested up to: 5.8 6 6 Requires PHP: 5.6 7 Stable tag: 2.0.1 07 Stable tag: 2.0.11 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 79 79 80 80 == Changelog == 81 82 = 2.0.11 - 2021-10-21 = 83 * Fix: Swap to using ZipArchive for Template Kit extraction 81 84 82 85 = 2.0.10 - 2021-09-17 = -
envato-elements/trunk/vendor/template-kit-import/inc/class-importer.php
r2614547 r2617529 43 43 44 44 /** 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 47 50 * 48 51 * @param string $temporary_zip_file … … 52 55 */ 53 56 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' ); 61 59 } 62 60 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; 67 76 } 77 } 68 78 69 return new \WP_Error( 'zip_error', 'Failed to unzip zip file' ); 70 } 79 $zip->extractTo( $destination_folder, $allowed_files ); 80 81 $zip->close(); 71 82 72 83 $extracted_zip_files = scandir( $destination_folder ); … … 76 87 $file_names = array(); 77 88 } 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 ) ) { 79 90 $this->delete_template_kit_folder( $destination_folder ); 80 91
Note: See TracChangeset
for help on using the changeset viewer.