Skip to content

Commit a807523

Browse files
wkaniachalasr
authored andcommitted
[Mime] Check that the path is a file in the DataPart::fromPath
1 parent 051f5a4 commit a807523

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 (!is_file($path) || !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
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy