From: Alexander Ebert Date: Wed, 17 Dec 2014 12:02:37 +0000 (+0100) Subject: Fixed uploading packages as styles X-Git-Tag: 2.1.0_Beta_2~18 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6bfddb8f6da72b3b0ad3e5ea941c336e99a3599c;p=GitHub%2FWoltLab%2FWCF.git Fixed uploading packages as styles --- diff --git a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php index faf2e87a0d..06fafb43ba 100755 --- a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php @@ -98,10 +98,8 @@ class PackageStartInstallForm extends AbstractForm { parent::validate(); if ($this->stylePackageImportLocation) { - $this->archive = new PackageArchive($this->stylePackageImportLocation, $this->package); - try { - $this->validateArchive('uploadPackage'); + $this->validateUploadPackage($this->stylePackageImportLocation); } catch (UserInputException $e) { WCF::getSession()->unregister('stylePackageImportLocation'); @@ -122,22 +120,28 @@ class PackageStartInstallForm extends AbstractForm { /** * Validates the upload package input. + * + * @param string $filename */ - protected function validateUploadPackage() { + protected function validateUploadPackage($filename = '') { $this->activeTabMenuItem = 'upload'; - if (empty($this->uploadPackage['tmp_name'])) { - throw new UserInputException('uploadPackage', 'uploadFailed'); - } - - // get filename - $this->uploadPackage['name'] = FileUtil::getTemporaryFilename('package_', preg_replace('!^.*(?=\.(?:tar\.gz|tgz|tar)$)!i', '', basename($this->uploadPackage['name']))); - - if (!@move_uploaded_file($this->uploadPackage['tmp_name'], $this->uploadPackage['name'])) { - throw new UserInputException('uploadPackage', 'uploadFailed'); + if (empty($filename)) { + if (empty($this->uploadPackage['tmp_name'])) { + throw new UserInputException('uploadPackage', 'uploadFailed'); + } + + // get filename + $this->uploadPackage['name'] = FileUtil::getTemporaryFilename('package_', preg_replace('!^.*(?=\.(?:tar\.gz|tgz|tar)$)!i', '', basename($this->uploadPackage['name']))); + + if (!@move_uploaded_file($this->uploadPackage['tmp_name'], $this->uploadPackage['name'])) { + throw new UserInputException('uploadPackage', 'uploadFailed'); + } + + $filename = $this->uploadPackage['name']; } - if (!PackageValidationManager::getInstance()->validate($this->uploadPackage['name'], false)) { + if (!PackageValidationManager::getInstance()->validate($filename, false)) { $exception = PackageValidationManager::getInstance()->getException(); if ($exception instanceof PackageValidationException) { switch ($exception->getCode()) {