Commit 0c34cdf1 authored by Benni Mack's avatar Benni Mack Committed by Susanne Moog
Browse files

[BUGFIX] Properly trimExplode allowed file extensions in IRRE / FAL

When a custom FAL / sys_file_reference inline element is registered, and
there are custom allowed file extensions, the property "elementBrowserAllowed"
is not properly run through "GeneralUtility::trimExplode()", however, all other
places do this properly.

The changes moves the trimExplode to the correct place, so uploading
of files directly in FormEngine works properly.

Resolves: #89540
Releases: master, 9.5
Change-Id: I9a486f8c932078629761bd86cc1d9455120fc7a5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62155

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarDaniel Gorges <daniel.gorges@b13.com>
Tested-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Reviewed-by: default avatarDaniel Gorges <daniel.gorges@b13.com>
Reviewed-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
parent e907140f
......@@ -495,6 +495,8 @@ class InlineControlContainer extends AbstractContainer
$elementBrowserEnabled = (bool)$inlineConfiguration['appearance']['elementBrowserEnabled'];
}
}
// Remove any white-spaces from the allowed extension lists
$allowed = implode(',', GeneralUtility::trimExplode(',', $allowed, true));
$browserParams = '|||' . $allowed . '|' . $objectPrefix;
$buttonStyle = '';
if (isset($inlineConfiguration['inline']['inlineNewRelationButtonStyle'])) {
......
......@@ -38,7 +38,7 @@ class ElementBrowser extends AbstractNode
$elementName = $parameterArray['itemFormElName'];
$config = $parameterArray['fieldConf']['config'];
$internalType = (string)$config['internal_type'];
$allowed = GeneralUtility::trimExplode(',', $config['allowed'], true);
$allowed = $config['allowed'];
if (isset($config['readOnly']) && $config['readOnly']) {
return [];
......@@ -67,10 +67,11 @@ class ElementBrowser extends AbstractNode
if (is_array($config['appearance']) && isset($config['appearance']['elementBrowserType'])) {
$elementBrowserType = $config['appearance']['elementBrowserType'];
}
$elementBrowserAllowed = implode(',', $allowed);
if (is_array($config['appearance']) && isset($config['appearance']['elementBrowserAllowed'])) {
$elementBrowserAllowed = $config['appearance']['elementBrowserAllowed'];
$allowed = $config['appearance']['elementBrowserAllowed'];
}
// Remove any white-spaces from the allowed extension lists
$elementBrowserAllowed = implode(',', GeneralUtility::trimExplode(',', $allowed, true));
return [
'iconIdentifier' => 'actions-insert-record',
......
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Backend\Tests\Unit\Form\FieldControl;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Form\FieldControl\ElementBrowser;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
class ElementBrowserTest extends UnitTestCase
{
/**
* @test
*/
public function renderTrimsAllowedExtensionsFromConfigSection(): void
{
$nodeFactory = $this->prophesize(NodeFactory::class);
$elementBrowser = new ElementBrowser($nodeFactory->reveal(), [
'fieldName' => 'somefield',
'isInlineChild' => false,
'tableName' => 'tt_content',
'inlineStructure' => [],
'parameterArray' => [
'itemFormElName' => '',
'fieldConf' => [
'config' => [
'internal_type' => 'file_reference',
'allowed' => 'jpg, png, bmp',
'appearance' => []
]
]
]
]);
$result = $elementBrowser->render();
self::assertSame($result['linkAttributes']['data-params'], '|||jpg,png,bmp|');
}
/**
* @test
*/
public function renderTrimsAllowedExtensionsFromAppearanceSection(): void
{
$nodeFactory = $this->prophesize(NodeFactory::class);
$elementBrowser = new ElementBrowser($nodeFactory->reveal(), [
'fieldName' => 'somefield',
'isInlineChild' => false,
'tableName' => 'tt_content',
'inlineStructure' => [],
'parameterArray' => [
'itemFormElName' => '',
'fieldConf' => [
'config' => [
'internal_type' => 'file_reference',
'allowed' => '',
'appearance' => [
'elementBrowserAllowed' => 'jpg, png, bmp'
]
]
]
]
]);
$result = $elementBrowser->render();
self::assertSame($result['linkAttributes']['data-params'], '|||jpg,png,bmp|');
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment