Commit 32e7a14b authored by Anja Leichsenring's avatar Anja Leichsenring Committed by Jan Helke
Browse files

[BUGFIX] Add check for valid directory name for TCA select fileFolder

If an invalid extension name is passed to a 'EXT:...' path, the
GeneralUtility::getFileAbsFileName function returns an empty string.
This results in a scan of '\' in the first place, and the resulting
error is not helpful for finding the source of the missing icons
in the TCA select box.
A check for a valid directory name and an exception in case of
failure will help the situation.

Resolves: #78737
Releases: master, 7.6
Change-Id: I9d5159eac9b511e879144789eecb40eafcc0288c
Reviewed-on: https://review.typo3.org/50699


Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Jan Helke's avatarJan Helke <typo3@helke.de>
Tested-by: Jan Helke's avatarJan Helke <typo3@helke.de>
parent df0dcddf
...@@ -390,6 +390,7 @@ abstract class AbstractItemProvider ...@@ -390,6 +390,7 @@ abstract class AbstractItemProvider
* @param string $fieldName Current handle field name * @param string $fieldName Current handle field name
* @param array $items Incoming items * @param array $items Incoming items
* @return array Modified item array * @return array Modified item array
* @throws \RuntimeException
*/ */
protected function addItemsFromFolder(array $result, $fieldName, array $items) protected function addItemsFromFolder(array $result, $fieldName, array $items)
{ {
...@@ -399,8 +400,14 @@ abstract class AbstractItemProvider ...@@ -399,8 +400,14 @@ abstract class AbstractItemProvider
return $items; return $items;
} }
$fileFolder = $result['processedTca']['columns'][$fieldName]['config']['fileFolder']; $fileFolderRaw = $result['processedTca']['columns'][$fieldName]['config']['fileFolder'];
$fileFolder = GeneralUtility::getFileAbsFileName($fileFolder); $fileFolder = GeneralUtility::getFileAbsFileName($fileFolderRaw);
if ($fileFolder === '') {
throw new \RuntimeException(
'Invalid folder given for item processing: ' . $fileFolderRaw . ' for table ' . $result['tableName'] . ', field ' . $fieldName,
1479399227
);
}
$fileFolder = rtrim($fileFolder, '/') . '/'; $fileFolder = rtrim($fileFolder, '/') . '/';
if (@is_dir($fileFolder)) { if (@is_dir($fileFolder)) {
......
...@@ -1248,6 +1248,32 @@ class TcaSelectItemsTest extends UnitTestCase ...@@ -1248,6 +1248,32 @@ class TcaSelectItemsTest extends UnitTestCase
$this->assertSame($expectedItems, $result['processedTca']['columns']['aField']['config']['items']); $this->assertSame($expectedItems, $result['processedTca']['columns']['aField']['config']['items']);
} }
/**
* @test
*/
public function addDataThrowsExceptionForInvalidFileFolder()
{
$input = [
'tableName' => 'aTable',
'databaseRow' => [],
'processedTca' => [
'columns' => [
'aField' => [
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'fileFolder' => 'EXT:non_existing/Resources/Public/',
],
],
],
],
];
$this->expectException(\RuntimeException::class);
$this->expectExceptionCode(1479399227);
$this->subject->addData($input);
}
/** /**
* @test * @test
*/ */
......
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