[BUGFIX] Respect empty allowedMimeTypes for file uploads 69/55869/5
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Thu, 22 Feb 2018 23:13:26 +0000 (00:13 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Thu, 15 Mar 2018 21:08:55 +0000 (22:08 +0100)
Make it possible to allow all mime types (except php) within file upload
form elements.
Since there are some default mime types configured within the ext:form
standard setup, you have to remove this default mime types within your
form definition (or reconfigure the default values within your custom
ext:form setup).

FileUpload:

properties:
  allowedMimeTypes:
    0: null
    1: null
    2: null
    3: null

ImageUpload:

properties:
  allowedMimeTypes:
    0: null
    1: null
    2: null

Releases: master, 8.7
Resolves: #82670
Change-Id: Ifa07cceb47978b913f36b8607d4df4724ae22eef
Reviewed-on: https://review.typo3.org/55869
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Tobi Kretschmann <tobi@tobishome.de>
Reviewed-by: Steffen Frese <steffenf14@gmail.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/form/Classes/Mvc/Property/PropertyMappingConfiguration.php

index 8137d54..9e5188b 100644 (file)
@@ -54,11 +54,18 @@ class PropertyMappingConfiguration
             /** @var \TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration $propertyMappingConfiguration */
             $propertyMappingConfiguration = $renderable->getRootForm()->getProcessingRule($renderable->getIdentifier())->getPropertyMappingConfiguration();
 
-            $mimeTypeValidator = GeneralUtility::makeInstance(ObjectManager::class)
-                ->get(MimeTypeValidator::class, ['allowedMimeTypes' => $renderable->getProperties()['allowedMimeTypes']]);
+            $allowedMimeTypes = [];
+            $validators = [];
+            if (is_array($renderable->getProperties()['allowedMimeTypes'])) {
+                $allowedMimeTypes = array_filter($renderable->getProperties()['allowedMimeTypes']);
+            }
+            if (!empty($allowedMimeTypes)) {
+                $mimeTypeValidator = GeneralUtility::makeInstance(ObjectManager::class)
+                    ->get(MimeTypeValidator::class, ['allowedMimeTypes' => $allowedMimeTypes]);
+                $validators = [$mimeTypeValidator];
+            }
 
             $processingRule = $renderable->getRootForm()->getProcessingRule($renderable->getIdentifier());
-            $validators = [$mimeTypeValidator];
             foreach ($processingRule->getValidators() as $validator) {
                 if (!($validator instanceof NotEmptyValidator)) {
                     $validators[] = $validator;