From a26f2dbe938755365ff681c36cf4b7fde7025da9 Mon Sep 17 00:00:00 2001
From: Thomas Hohn <tho@gyldendal.dk>
Date: Tue, 12 Dec 2023 13:47:26 +0100
Subject: [PATCH] [BUGFIX] Avoid exception on trailing comma in
 include_static_file.txt

If an entry in the include_static_file.txt file contains a trailing
comma, a RuntimeException (1651137904) is thrown. The problem is a
check whether the path contains 'EXT:', in this case the second path
is an empty string and hence the exception is thrown.

The change removes empty strings when splitting the entries in the
file by comma.

Resolves: #102659
Releases: main, 12.4
Change-Id: Ic2290b0b153487c7e982b4bca6b220a6bb9abf55
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82121
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Benni Mack <benni@typo3.org>
---
 .../Classes/TypoScript/IncludeTree/SysTemplateTreeBuilder.php   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/typo3/sysext/core/Classes/TypoScript/IncludeTree/SysTemplateTreeBuilder.php b/typo3/sysext/core/Classes/TypoScript/IncludeTree/SysTemplateTreeBuilder.php
index f8222d4c1838..1256b812c98d 100644
--- a/typo3/sysext/core/Classes/TypoScript/IncludeTree/SysTemplateTreeBuilder.php
+++ b/typo3/sysext/core/Classes/TypoScript/IncludeTree/SysTemplateTreeBuilder.php
@@ -328,7 +328,7 @@ final class SysTemplateTreeBuilder
             $parentNode->addChild($includeStaticFileFileInclude);
             $includeStaticFileFileIncludeContent = (string)file_get_contents($includeStaticFileFileIncludePath);
             // @todo: There is no array_unique() for DB based include_static_file content?!
-            $includeStaticFileFileIncludeArray = array_unique(GeneralUtility::trimExplode(',', $includeStaticFileFileIncludeContent));
+            $includeStaticFileFileIncludeArray = array_unique(GeneralUtility::trimExplode(',', $includeStaticFileFileIncludeContent, true));
             foreach ($includeStaticFileFileIncludeArray as $includeStaticFileFileIncludeString) {
                 $this->handleSingleIncludeStaticFile($includeStaticFileFileInclude, $includeStaticFileFileIncludeString);
             }
-- 
GitLab