Bump php-mime-mail-parser library to 9.0.1

This commit is contained in:
johnnyq 2025-01-24 22:07:49 -05:00
parent 927725de7d
commit fb17dbb1fb
3 changed files with 12 additions and 7 deletions

View File

@ -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:

View File

@ -29,7 +29,7 @@ class MiddlewareStack
*
* @param Middleware $middleware
*/
public function __construct(MiddleWareContracts $middleware = null)
public function __construct(?MiddleWareContracts $middleware = null)
{
$this->middleware = $middleware;
}

View File

@ -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<int, array{'display': string, 'address': string, 'is_group': bool}>
*/
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')
{