[BUGFIX] Cannot upload an extension as zip 37/24037/3
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:13 +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
typo3/sysext/extensionmanager/Classes/Controller/UploadExtensionFileController.php
typo3/sysext/extensionmanager/Tests/Unit/Controller/UploadExtensionFileControllerTest.php

index 725e4a9..08af8ae 100644 (file)
@@ -137,7 +137,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);
                }
index b475eee..0364a4b 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'
                        )
                );
        }