diff --git a/plugins/php-mime-mail-parser/Attachment.php b/plugins/php-mime-mail-parser/Attachment.php index 1a731635..9b001a5b 100644 --- a/plugins/php-mime-mail-parser/Attachment.php +++ b/plugins/php-mime-mail-parser/Attachment.php @@ -241,7 +241,7 @@ class Attachment case Parser::ATTACHMENT_RANDOM_FILENAME: $fileInfo = pathinfo($this->getFilename()); $extension = empty($fileInfo['extension']) ? '' : '.'.$fileInfo['extension']; - $attachment_path = $attach_dir.uniqid().$extension; + $attachment_path = $attach_dir.bin2hex(random_bytes(16)).$extension; break; case Parser::ATTACHMENT_DUPLICATE_THROW: case Parser::ATTACHMENT_DUPLICATE_SUFFIX: diff --git a/plugins/php-mime-mail-parser/MiddlewareStack.php b/plugins/php-mime-mail-parser/MiddlewareStack.php index 3ef6da93..ecab6445 100644 --- a/plugins/php-mime-mail-parser/MiddlewareStack.php +++ b/plugins/php-mime-mail-parser/MiddlewareStack.php @@ -29,7 +29,7 @@ class MiddlewareStack * * @param Middleware $middleware */ - public function __construct(MiddleWareContracts $middleware = null) + public function __construct(?MiddleWareContracts $middleware = null) { $this->middleware = $middleware; } diff --git a/plugins/php-mime-mail-parser/Parser.php b/plugins/php-mime-mail-parser/Parser.php index 7f8a1de9..fcc4d7c6 100644 --- a/plugins/php-mime-mail-parser/Parser.php +++ b/plugins/php-mime-mail-parser/Parser.php @@ -74,7 +74,7 @@ class Parser * * @param CharsetManager|null $charset */ - public function __construct(CharsetManager $charset = null) + public function __construct(?CharsetManager $charset = null) { if ($charset == null) { $charset = new Charset(); @@ -208,6 +208,11 @@ class Parser */ protected function parse() { + if (!$this->resource) { + throw new Exception( + 'MIME message cannot be parsed' + ); + } $structure = mailparse_msg_get_structure($this->resource); $this->parts = []; foreach ($structure as $part_id) { @@ -404,7 +409,7 @@ class Parser $body = empty($inline_parts) ? '' : $inline_parts[0]; } else { throw new Exception( - 'Invalid type specified for getMessageBody(). Expected: text, html or htmlEmbeded.' + 'Invalid type specified for getMessageBody(). Expected: text, html or htmlEmbedded.' ); } @@ -450,7 +455,7 @@ class Parser * * @param string $name Header name (case-insensitive) * - * @return array + * @return array */ public function getAddresses($name) { @@ -464,9 +469,9 @@ class Parser } /** - * Returns the attachments contents in order of appearance + * Returns the inline parts contents (text or HTML) * - * @return Attachment[] + * @return string[] The decoded inline parts. */ public function getInlineParts($type = 'text') {