Check whether path is file in DataPart::fromPath()

This commit is contained in:
Ondřej Frei 2020-04-01 17:33:44 +02:00 committed by Fabien Potencier
parent a9ffbf4ccf
commit 9e3670e140
1 changed files with 4 additions and 0 deletions

View File

@ -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));
}