[BUGFIX] Ignore invalid files in LocalDriver::getDirectoryItemList 45/51845/3
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 10:57:36 +0000 (11:57 +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/51845
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php

index 552fb23..e3679fc 100644 (file)
@@ -386,22 +386,25 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver
             // go on to the next iterator item now as we might skip this one early
             $iterator->next();
 
-            if (
-                !$this->applyFilterMethodsToDirectoryItem(
-                    $filterMethods,
-                    $iteratorItem['name'],
-                    $iteratorItem['identifier'],
-                    $this->getParentFolderIdentifierOfIdentifier($iteratorItem['identifier'])
-                )
-            ) {
-                continue;
-            }
+            try {
+                if (
+                    !$this->applyFilterMethodsToDirectoryItem(
+                        $filterMethods,
+                        $iteratorItem['name'],
+                        $iteratorItem['identifier'],
+                        $this->getParentFolderIdentifierOfIdentifier($iteratorItem['identifier'])
+                    )
+                ) {
+                    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;
     }