[BUGFIX] Allow longer file-endings in typoscript directory includes 58/54458/2
authorMathias Schreiber <mathias.schreiber@typo3.org>
Wed, 18 Oct 2017 23:13:52 +0000 (01:13 +0200)
committerBenjamin Kott <benjamin.kott@outlook.com>
Fri, 20 Oct 2017 12:56:55 +0000 (14:56 +0200)
Directory includes now allow more liberal substrings to include files
not only based on their extension (*.typoscript) but based on the last
part of their filename (*.setup.typoscript).

Resolves: #82543
Releases: master, 8.7
Change-Id: Ic2111b98a6e3935b542addfd712f4256aa40f888
Reviewed-on: https://review.typo3.org/54443
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Benjamin Kott <benjamin.kott@outlook.com>
Tested-by: Benjamin Kott <benjamin.kott@outlook.com>
(cherry picked from commit 9ddb3cb19a7ea4b5c3ab2b411c0f936fcf777842)
Reviewed-on: https://review.typo3.org/54458

typo3/sysext/core/Classes/Utility/GeneralUtility.php

index 80ae9fb..26a4a3e 100644 (file)
@@ -2459,6 +2459,7 @@ class GeneralUtility
         }
 
         $pathPrefix = $path . '/';
+        $allowedFileExtensionArray = self::trimExplode(',', $extensionList);
         $extensionList = ',' . str_replace(' ', '', $extensionList) . ',';
         $files = [];
         foreach ($rawFileList as $entry) {
@@ -2467,15 +2468,17 @@ class GeneralUtility
                 continue;
             }
 
-            if (
-                ($extensionList === ',,' || stripos($extensionList, ',' . pathinfo($entry, PATHINFO_EXTENSION) . ',') !== false)
-                && ($excludePattern === '' || !preg_match(('/^' . $excludePattern . '$/'), $entry))
-            ) {
-                if ($order !== 'mtime') {
-                    $files[] = $entry;
-                } else {
-                    // Store the value in the key so we can do a fast asort later.
-                    $files[$entry] = filemtime($completePathToEntry);
+            foreach ($allowedFileExtensionArray as $allowedFileExtension) {
+                if (
+                    ($extensionList === ',,' || stripos($extensionList, ',' . substr($entry, strlen($allowedFileExtension)*-1, strlen($allowedFileExtension)) . ',') !== false)
+                    && ($excludePattern === '' || !preg_match(('/^' . $excludePattern . '$/'), $entry))
+                ) {
+                    if ($order !== 'mtime') {
+                        $files[] = $entry;
+                    } else {
+                        // Store the value in the key so we can do a fast asort later.
+                        $files[$entry] = filemtime($completePathToEntry);
+                    }
                 }
             }
         }