From fc12d545da74cf6abb01540f2dc069d26e7c14c4 Mon Sep 17 00:00:00 2001
From: Daniel Goerz <dlg@lightwerk.com>
Date: Tue, 27 Jun 2017 12:35:22 +0200
Subject: [PATCH] [BUGFIX] Allow whitespaces in list of file extensions

This ensures that spaces can be used to format the list of file
extensions for <INCLUDE_TYPOSCRIPT>.

Resolves: #81709
Releases: master, 8.7
Change-Id: Ia0c830df52b18a3dae7bd724c4bd5ee3b845e00f
Reviewed-on: https://review.typo3.org/53337
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../core/Classes/Utility/GeneralUtility.php   |  2 +-
 .../Tests/Unit/Utility/GeneralUtilityTest.php | 29 +++++++++++++++++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
index 0aa26fcf62c3..ef62095c5699 100644
--- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php
+++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
@@ -2213,7 +2213,7 @@ class GeneralUtility
         }
 
         $pathPrefix = $path . '/';
-        $extensionList = ',' . $extensionList . ',';
+        $extensionList = ',' . str_replace(' ', '', $extensionList) . ',';
         $files = [];
         foreach ($rawFileList as $entry) {
             $completePathToEntry = $pathPrefix . $entry;
diff --git a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
index 0bfcbc136cc9..7534fa71d0fb 100644
--- a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
+++ b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
@@ -3272,14 +3272,39 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     }
 
     /**
+     * Data provider for getFilesInDirByExtensionFindsFiles
+     *
+     * @return array
+     */
+    public function fileExtensionDataProvider()
+    {
+        return [
+            'no space' => [
+                'txt,js,css'
+            ],
+            'spaces' => [
+                'txt, js, css'
+            ],
+            'mixed' => [
+                'txt,js, css'
+            ],
+            'wild' => [
+                'txt,     js  ,         css'
+            ]
+        ];
+    }
+
+    /**
+     * @dataProvider fileExtensionDataProvider
      * @test
      */
-    public function getFilesInDirByExtensionFindsFiles()
+    public function getFilesInDirByExtensionFindsFiles($fileExtensions)
     {
         $vfsStreamUrl = $this->getFilesInDirCreateTestDirectory();
-        $files = GeneralUtility::getFilesInDir($vfsStreamUrl, 'txt,js');
+        $files = GeneralUtility::getFilesInDir($vfsStreamUrl, $fileExtensions);
         $this->assertContains('testA.txt', $files);
         $this->assertContains('test.js', $files);
+        $this->assertContains('test.css', $files);
     }
 
     /**
-- 
GitLab