Skip to content

Commit 030b10c

Browse files
committed
bug #36304 Check whether path is file in DataPart::fromPath() (freiondrej)
This PR was submitted for the 5.0 branch but it was squashed and merged into the 4.4 branch instead. Discussion ---------- Check whether path is file in DataPart::fromPath() | Q | A | ------------- | --- | Branch? | 5.0 | Bug fix? | yes | New feature? | no | Deprecations? | no Method `getBody()` uses stream_get_contents() to retrieve the body, however it fails to do so when the stream is a directory. Commits ------- 9e3670e Check whether path is file in DataPart::fromPath()
2 parents a9ffbf4 + 9e3670e commit 030b10c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public static function fromPath(string $path, string $name = null, string $conte
5656
$contentType = self::$mimeTypes->getMimeTypes($ext)[0] ?? 'application/octet-stream';
5757
}
5858

59+
if (false === is_readable($path)) {
60+
throw new InvalidArgumentException(sprintf('Path "%s" is not readable.', $path));
61+
}
62+
5963
if (false === $handle = @fopen($path, 'r', false)) {
6064
throw new InvalidArgumentException(sprintf('Unable to open path "%s".', $path));
6165
}

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