Skip to content

Navigation Menu

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 030b10c

Browse filesBrowse 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
Copy full SHA for 030b10c

File tree

1 file changed

+4
-0
lines changed
Filter options

1 file changed

+4
-0
lines changed

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

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