[FOLLOWUP][BUGFIX] ImageViewHelper should catch exceptions 66/45166/3
authorAndreas Allacher <andreas@allacher.com>
Mon, 7 Dec 2015 09:57:36 +0000 (10:57 +0100)
committerFrank Nägler <frank.naegler@typo3.org>
Mon, 7 Dec 2015 15:20:28 +0000 (16:20 +0100)
We also need to catch RuntimeException and InvalidArgumentException
InvalidArgumentException might be thrown if a storage does not exist.
RuntimeException if a file is outside a storage.

Change-Id: I994d8e7ef8b515f23ccc01847cefac0202f14b6f
Releases: master, 6.2
Resolves: #71686
Reviewed-on: https://review.typo3.org/45166
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Josef Glatz <josef.glatz@typo3.org>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
typo3/sysext/fluid/Classes/ViewHelpers/ImageViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Uri/ImageViewHelper.php

index 6f8e365..78a12f4 100644 (file)
@@ -140,7 +140,13 @@ class ImageViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedV
                 $this->tag->addAttribute('title', $title);
             }
         } catch (ResourceDoesNotExistException $e) {
+            // thrown if file does not exist
         } catch (\UnexpectedValueException $e) {
+            // thrown if a file has been replaced with a folder
+        } catch (\RuntimeException $e) {
+            // RuntimeException thrown if a file is outside of a storage
+        } catch (\InvalidArgumentException $e) {
+            // thrown if file storage does not exist
         }
 
         return $this->tag->render();
index 7c13aed..6b82b93 100644 (file)
@@ -144,7 +144,13 @@ class ImageViewHelper extends AbstractViewHelper implements CompilableInterface
             $processedImage = $imageService->applyProcessingInstructions($image, $processingInstructions);
             return $imageService->getImageUri($processedImage, $absolute);
         } catch (ResourceDoesNotExistException $e) {
+            // thrown if file does not exist
         } catch (\UnexpectedValueException $e) {
+            // thrown if a file has been replaced with a folder
+        } catch (\RuntimeException $e) {
+            // RuntimeException thrown if a file is outside of a storage
+        } catch (\InvalidArgumentException $e) {
+            // thrown if file storage does not exist
         }
         return '';
     }