Skip to content

Commit

Permalink
use FileSystem::read() instead of native file_get_contents() (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek authored and dg committed May 14, 2020
1 parent e61b0ef commit b4027a0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Bridges/MailDI/MailExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function loadConfiguration()

if ($this->config['dkim']) {
$dkim = $this->config['dkim'];
$dkim['privateKey'] = file_get_contents($dkim['privateKey']);
$dkim['privateKey'] = Nette\Utils\FileSystem::read($dkim['privateKey']);
unset($this->config['dkim']);

$signer = $builder->addDefinition($this->prefix('signer'))
Expand Down
5 changes: 1 addition & 4 deletions src/Mail/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,7 @@ private function createAttachment(string $file, ?string $content, ?string $conte
{
$part = new MimePart;
if ($content === null) {
$content = @file_get_contents($file); // @ is escalated to exception
if ($content === false) {
throw new Nette\FileNotFoundException("Unable to read file '$file'.");
}
$content = Nette\Utils\FileSystem::read($file);
}
if (!$contentType) {
$contentType = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $content);
Expand Down

0 comments on commit b4027a0

Please sign in to comment.