8000 Check that the path is a file in the DataPart::fromPath · symfony/symfony@f367c56 · GitHub
[go: up one dir, main page]

Skip to content

Commit f367c56

Browse files
committed
Check that the path is a file in the DataPart::fromPath
1 parent 051f5a4 commit f367c56

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Symfony/Component/Mime/Part/DataPart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static function fromPath(string $path, string $name = null, string $conte
6161
$contentType = self::$mimeTypes->getMimeTypes($ext)[0] ?? 'application/octet-stream';
6262
}
6363

64-
if (false === is_readable($path)) {
64+
if (false === is_file($path) || false === is_readable($path)) {
6565
throw new InvalidArgumentException(sprintf('Path "%s" is not readable.', $path));
6666
}
6767

src/Symfony/Component/Mime/Tests/Part/DataPartTest.php

Lines changed: 7 additions & 0 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Mime\Tests\Part;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Mime\Exception\InvalidArgumentException;
1516
use Symfony\Component\Mime\Header\Headers;
1617
use Symfony\Component\Mime\Header\IdentificationHeader;
1718
use Symfony\Component\Mime\Header\ParameterizedHeader;
@@ -127,6 +128,12 @@ public function testFromPathWithMeta()
127128
), $p->getPreparedHeaders());
128129
}
129130

131+
public function testFromPathWithNotAFile()
132+
{
133+
$this->expectException(InvalidArgumentException::class);
134+
DataPart::fromPath( __DIR__.'/../Fixtures/mimetypes/');
135+
}
136+
130137
public function testHasContentId()
131138
{
132139
$p = new DataPart('content');

0 commit comments

Comments
 (0)
0