diff --git a/src/src/Environment/ExtensionDownload/ExtensionZip.php b/src/src/Environment/ExtensionDownload/ExtensionZip.php index 882ace29..d26615a1 100644 --- a/src/src/Environment/ExtensionDownload/ExtensionZip.php +++ b/src/src/Environment/ExtensionDownload/ExtensionZip.php @@ -33,8 +33,8 @@ public function extract_zip( string $zip_file, string $extract_to ): void { } } - // Make sure $extract_to is within Config Dir. - if ( strpos( normalize_path( $extract_to ), Config::get_qit_dir() ) !== 0 ) { + // Make sure $extract_to is within Config Dir or sys_get_temp_dir. + if ( strpos( normalize_path( $extract_to ), Config::get_qit_dir() ) !== 0 && strpos( normalize_path( $extract_to ), normalize_path( sys_get_temp_dir() ) ) !== 0 ) { throw new \RuntimeException( 'Invalid directory.' ); } diff --git a/src/src/Environment/ExtensionDownload/Handlers/FileHandler.php b/src/src/Environment/ExtensionDownload/Handlers/FileHandler.php index 66ef4284..18c84a22 100644 --- a/src/src/Environment/ExtensionDownload/Handlers/FileHandler.php +++ b/src/src/Environment/ExtensionDownload/Handlers/FileHandler.php @@ -74,13 +74,13 @@ protected function find_type_in_zip( Extension $extension ): void { $tmp_dir = sys_get_temp_dir() . '/' . uniqid( 'qit-cli-' ); // Make tmp dir. - if ( ! mkdir( $tmp_dir, 0777, true ) ) { + if ( ! mkdir( $tmp_dir, 0755, true ) ) { throw new \RuntimeException( 'Could not create temporary directory: ' . $tmp_dir ); } App::make( ExtensionZip::class )->extract_zip( $extension->path, $tmp_dir ); - $ext_copy = clone $extension; - $ext_copy->path = $tmp_dir; + $ext_copy = clone $extension; + $ext_copy->extension_identifier = $tmp_dir; $this->find_type_in_dir( $ext_copy ); } } \ No newline at end of file