Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 03bccf1

Browse filesBrowse files
committed
bug #46535 [Mime] Check that the path is a file in the DataPart::fromPath (wkania)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [Mime] Check that the path is a file in the DataPart::fromPath | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | The directory can also be readable. Fix to the [PR](#36304). Found it while working on another fix related to this method. Commits ------- a807523 [Mime] Check that the path is a file in the DataPart::fromPath
2 parents f96da6d + a807523 commit 03bccf1
Copy full SHA for 03bccf1

File tree

Expand file treeCollapse file tree

2 files changed

+8
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Part/DataPart.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Tests/Part/DataPartTest.php
+7Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.