From 59a78cd9ace2648e6e44b02ca90cc9bfc5212909 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 12 Dec 2024 08:34:26 +0100 Subject: [PATCH] Check if path is a file in FileSystemLoader --- Binary/Loader/FileSystemLoader.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Binary/Loader/FileSystemLoader.php b/Binary/Loader/FileSystemLoader.php index 1e8373ff..6185e46c 100644 --- a/Binary/Loader/FileSystemLoader.php +++ b/Binary/Loader/FileSystemLoader.php @@ -12,6 +12,7 @@ namespace Liip\ImagineBundle\Binary\Loader; use Liip\ImagineBundle\Binary\Locator\LocatorInterface; +use Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException; use Liip\ImagineBundle\Exception\InvalidArgumentException; use Liip\ImagineBundle\Model\FileBinary; use Symfony\Component\HttpFoundation\File\MimeType\ExtensionGuesserInterface as DeprecatedExtensionGuesserInterface; @@ -69,6 +70,11 @@ public function __construct( public function find($path) { $path = $this->locator->locate($path); + + if (\is_file($path) === false) { + throw new NotLoadableException(\sprintf('Source image: "%s" is no file.', $path)); + } + $mimeType = $this->mimeTypeGuesser instanceof DeprecatedMimeTypeGuesserInterface ? $this->mimeTypeGuesser->guess($path) : $this->mimeTypeGuesser->guessMimeType($path); $extension = $this->getExtension($mimeType);