[BUGFIX] Catch exceptions while dumping a file 80/48080/5
authorWouter Wolters <typo3@wouterwolters.nl>
Wed, 11 May 2016 14:14:53 +0000 (16:14 +0200)
committerFrans Saris <franssaris@gmail.com>
Tue, 15 Nov 2016 15:31:45 +0000 (16:31 +0100)
While dumping a file in the frontend no exceptions are
caught. When a exception happens a 500 HTTP status is thrown.

Catch all exceptions to return the correct 404 HTTP status.

Releases: master,7.6,6.2
Resolves: #76153
Change-Id: Ice7097b6a41432ec580f99185d352307c5f55394
Reviewed-on: https://review.typo3.org/48080
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
typo3/sysext/core/Classes/Controller/FileDumpController.php

index 7dd268a..b8b5a78 100644 (file)
@@ -57,13 +57,17 @@ class FileDumpController
 
         if (GeneralUtility::hmac(implode('|', $parameters), 'resourceStorageDumpFile') === $this->getGetOrPost($request, 'token')) {
             if (isset($parameters['f'])) {
-                $file = ResourceFactory::getInstance()->getFileObject($parameters['f']);
-                if ($file->isDeleted() || $file->isMissing()) {
+                try {
+                    $file = ResourceFactory::getInstance()->getFileObject($parameters['f']);
+                    if ($file->isDeleted() || $file->isMissing()) {
+                        $file = null;
+                    }
+                } catch (\Exception $e) {
                     $file = null;
                 }
             } else {
                 $file = GeneralUtility::makeInstance(ProcessedFileRepository::class)->findByUid($parameters['p']);
-                if ($file->isDeleted()) {
+                if (!$file || $file->isDeleted()) {
                     $file = null;
                 }
             }