-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Check whether path is file in DataPart::fromPath() #36304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
+4
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maxhelias
reviewed
Jun 10, 2020
@@ -56,6 +56,10 @@ public static function fromPath(string $path, string $name = null, string $conte | |||
$contentType = self::$mimeTypes->getMimeTypes($ext)[0] ?? 'application/octet-stream'; | |||
} | |||
|
|||
if (false === is_file($path)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think to put "is_readable"? And adapt the exception message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maxhelias done :)
fabpot
approved these changes
Jun 22, 2020
Thank you @freiondrej. |
This was referenced Jul 24, 2020
Merged
Merged
Merged
chalasr
added a commit
that referenced
this pull request
Jun 1, 2022
…Path (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
nicolas-grekas
added a commit
that referenced
this pull request
Jun 9, 2022
This PR was merged into the 4.4 branch. Discussion ---------- [Mime] Allow url as a path in the DataPart::fromPath | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A While switching from the Swift Mailer to the Symfony Mailer I encounter a bug `Symfony\Component\Mime\Exception\InvalidArgumentException`. Steps to reproduce: 1. I have created an email with an attachment that is a remote file and saw `An exception has been thrown during the rendering of a template`. 2. Also when I have visited tab E-mails in the Symfony Profiler, saw the same Symfony Exception page DataPart can't be created from url, even if `fopen` can open url. Apparently, before Symfony [4.4.11](#36304) this worked with URLs. At least in the context of email with attachments. PHP doesn't support rewind on non-local streams, so calling multiple times method `getBody` from `TextPart` would return an empty string. So in another context, it worked partially. Additional notes: 1. Network example based on [this](https://github.com/symfony/symfony/blob/60ce5a3dfbd90fad60cd39fcb3d7bf7888a48659/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php#L165) 2. Base64Encoder chunk split base64 encoded string so I only check the first line Commits ------- 12bf8cb [Mime] Allow url as a path in the DataPart::fromPath
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Method
getBody()
uses stream_get_contents() to retrieve the body, however it fails to do so when the stream is a directory.