[BUGFIX] Cannot upload an extension as zip 31/24531/2
authorXavier Perseguers <xavier@typo3.org>
Wed, 25 Sep 2013 07:41:58 +0000 (09:41 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 10 Oct 2013 16:02:54 +0000 (18:02 +0200)
The file extension ".zip" should be systematically removed when
extracting the extension key from the uploaded file name.

Fixes: #52178
Releases: 6.2, 6.1, 6.0
Change-Id: I5316b995533fa324d3b19407ad9bb6365ab8858b
Reviewed-on: https://review.typo3.org/24037
Reviewed-by: Sebastian Fischer
Tested-by: Sebastian Fischer
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
(cherry picked from commit e1db658c3f6d332f4c1971f333b55c168aed43df)
Reviewed-on: https://review.typo3.org/24531

typo3/sysext/extensionmanager/Classes/Controller/UploadExtensionFileController.php
typo3/sysext/extensionmanager/Tests/Unit/Controller/UploadExtensionFileControllerTest.php

index 9a53fdb..49dbe29 100644 (file)
@@ -158,7 +158,7 @@ class UploadExtensionFileController extends \TYPO3\CMS\Extensionmanager\Controll
         */
        protected function getExtensionFromZipFile($file, $fileName, $overwrite = FALSE) {
                        // Remove version and ending from filename to determine extension key
-               $extensionKey = preg_replace('/_(\d+)(\.|\-)(\d+)(\.|\-)(\d+).*/i', '', strtolower($fileName));
+               $extensionKey = preg_replace('/_(\d+)(\.|\-)(\d+)(\.|\-)(\d+).*/i', '', strtolower(substr($fileName, 0, -4)));
                if (!$overwrite && $this->installUtility->isAvailable($extensionKey)) {
                        throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Extension is already available and overwriting is disabled.', 1342864311);
                }
@@ -169,4 +169,4 @@ class UploadExtensionFileController extends \TYPO3\CMS\Extensionmanager\Controll
 
 }
 
-?>
\ No newline at end of file
+?>
index 128392b..f4c479e 100644 (file)
@@ -58,6 +58,10 @@ class UploadExtensionFileControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\Ba
                        'characters after version with extra space' => array(
                                'extension_1-2-3 (1).zip',
                                'extension'
+                       ),
+                       'no version' => array(
+                               'extension.zip',
+                               'extension'
                        )
                );
        }
@@ -83,4 +87,4 @@ class UploadExtensionFileControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\Ba
 
 }
 
-?>
\ No newline at end of file
+?>