From 9e3670e140579c8331779776125e88af68269ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Frei?= <37588173+freiondrej@users.noreply.github.com> Date: Wed, 1 Apr 2020 17:33:44 +0200 Subject: [PATCH] Check whether path is file in DataPart::fromPath() --- src/Symfony/Component/Mime/Part/DataPart.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Mime/Part/DataPart.php b/src/Symfony/Component/Mime/Part/DataPart.php index c6f1cb9742..17e3e3c0d3 100644 --- a/src/Symfony/Component/Mime/Part/DataPart.php +++ b/src/Symfony/Component/Mime/Part/DataPart.php @@ -56,6 +56,10 @@ class DataPart extends TextPart $contentType = self::$mimeTypes->getMimeTypes($ext)[0] ?? 'application/octet-stream'; } + if (false === is_readable($path)) { + throw new InvalidArgumentException(sprintf('Path "%s" is not readable.', $path)); + } + if (false === $handle = @fopen($path, 'r', false)) { throw new InvalidArgumentException(sprintf('Unable to open path "%s".', $path)); }