[BUGFIX] Ignore invalid files in LocalDriver::getDirectoryItemList 55/51655/2
authorNicole Cordes <typo3@cordes.co>
Mon, 13 Feb 2017 13:22:39 +0000 (14:22 +0100)
committerNicole Cordes <typo3@cordes.co>
Sat, 25 Feb 2017 09:49:14 +0000 (10:49 +0100)
Due to some security changes in GeneralUtility::validPathStr some
wrongly encoded files are now returned as invalid. This breaks e.g. the
file list.
This patch adds a try/catch block to ignore invalid files and return the
valid ones.

Resolves: #79776
Releases: master, 7.6, 6.2
Change-Id: Iaa3697b04c123bba61a426fdf39ee3959f68b705
Reviewed-on: https://review.typo3.org/51655
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Tobias Liebig <tobias.liebig@typo3.org>
Tested-by: Tobias Liebig <tobias.liebig@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Sascha Egerer <sascha@sascha-egerer.de>
Tested-by: Sascha Egerer <sascha@sascha-egerer.de>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php

index cc41f4d..c969b91 100644 (file)
@@ -372,22 +372,25 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver
             // go on to the next iterator item now as we might skip this one early
             $iterator->next();
 
-            if (
+            try {
+                if (
                 !$this->applyFilterMethodsToDirectoryItem(
                     $filterMethods,
                     $iteratorItem['name'],
                     $iteratorItem['identifier'],
                     $this->getParentFolderIdentifierOfIdentifier($iteratorItem['identifier'])
                 )
-            ) {
-                continue;
-            }
+                ) {
+                    continue;
+                }
 
-            $items[$iteratorItem['identifier']] = $iteratorItem['identifier'];
-            // Decrement item counter to make sure we only return $numberOfItems
-            // we cannot do this earlier in the method (unlike moving the iterator forward) because we only add the
-            // item here
-            --$c;
+                $items[$iteratorItem['identifier']] = $iteratorItem['identifier'];
+                // Decrement item counter to make sure we only return $numberOfItems
+                // we cannot do this earlier in the method (unlike moving the iterator forward) because we only add the
+                // item here
+                --$c;
+            } catch (Exception\InvalidPathException $e) {
+            }
         }
         return $items;
     }