mirror of
https://github.com/itflow-org/itflow
synced 2026-08-16 12:35:11 +00:00
Bump ImapEngine from 1.25.1 to 1.25.2
This commit is contained in:
@@ -6,6 +6,7 @@ use Countable;
|
||||
use DirectoryTree\ImapEngine\Connection\Responses\Data\ListData;
|
||||
use DirectoryTree\ImapEngine\Connection\Tokens\Nil;
|
||||
use DirectoryTree\ImapEngine\Connection\Tokens\Token;
|
||||
use DirectoryTree\ImapEngine\Support\MimeParameterParser;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use IteratorAggregate;
|
||||
use JsonSerializable;
|
||||
@@ -63,7 +64,7 @@ class BodyStructureCollection implements Arrayable, Countable, IteratorAggregate
|
||||
if ($subtypeIndex) {
|
||||
foreach (array_slice($tokens, $subtypeIndex + 1) as $token) {
|
||||
if ($token instanceof ListData && ! static::isDispositionList($token)) {
|
||||
$parameters = $token->toKeyValuePairs();
|
||||
$parameters = MimeParameterParser::parse($token->toKeyValuePairs());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace DirectoryTree\ImapEngine;
|
||||
use DirectoryTree\ImapEngine\Connection\Responses\Data\ListData;
|
||||
use DirectoryTree\ImapEngine\Connection\Tokens\Nil;
|
||||
use DirectoryTree\ImapEngine\Connection\Tokens\Token;
|
||||
use DirectoryTree\ImapEngine\Support\MimeParameterParser;
|
||||
use DirectoryTree\ImapEngine\Support\Str;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use JsonSerializable;
|
||||
|
||||
@@ -45,9 +47,13 @@ class BodyStructurePart implements Arrayable, JsonSerializable
|
||||
partNumber: $partNumber,
|
||||
type: strtolower(static::tokenValueAt($tokens, 0) ?? 'text'),
|
||||
subtype: strtolower(static::tokenValueAt($tokens, 1) ?? 'plain'),
|
||||
parameters: isset($tokens[2]) && $tokens[2] instanceof ListData ? $tokens[2]->toKeyValuePairs() : [],
|
||||
parameters: isset($tokens[2]) && $tokens[2] instanceof ListData
|
||||
? MimeParameterParser::parse($tokens[2]->toKeyValuePairs())
|
||||
: [],
|
||||
id: static::tokenValueAt($tokens, 3),
|
||||
description: static::tokenValueAt($tokens, 4),
|
||||
description: is_null($description = static::tokenValueAt($tokens, 4))
|
||||
? null
|
||||
: Str::decodeMimeHeader($description),
|
||||
encoding: static::tokenValueAt($tokens, 5),
|
||||
size: static::tokenIntValueAt($tokens, 6),
|
||||
lines: static::tokenIntValueAt($tokens, 7),
|
||||
@@ -62,7 +68,9 @@ class BodyStructurePart implements Arrayable, JsonSerializable
|
||||
*/
|
||||
protected static function tokenValueAt(array $tokens, int $index): ?string
|
||||
{
|
||||
$token = $tokens[$index] ?? null;
|
||||
if (is_null($token = $tokens[$index] ?? null)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! $token instanceof Token || $token instanceof Nil) {
|
||||
return null;
|
||||
@@ -80,7 +88,7 @@ class BodyStructurePart implements Arrayable, JsonSerializable
|
||||
{
|
||||
$value = static::tokenValueAt($tokens, $index);
|
||||
|
||||
return $value === null ? null : (int) $value;
|
||||
return is_null($value) ? null : (int) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,7 +192,7 @@ class BodyStructurePart implements Arrayable, JsonSerializable
|
||||
*/
|
||||
public function filename(): ?string
|
||||
{
|
||||
return $this->disposition?->filename() ?? $this->parameters['name'] ?? null;
|
||||
return $this->disposition?->filename() ?? $this->parameter('name');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace DirectoryTree\ImapEngine;
|
||||
use DirectoryTree\ImapEngine\Connection\Responses\Data\ListData;
|
||||
use DirectoryTree\ImapEngine\Connection\Tokens\Token;
|
||||
use DirectoryTree\ImapEngine\Enums\ContentDispositionType;
|
||||
use DirectoryTree\ImapEngine\Support\MimeParameterParser;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use JsonSerializable;
|
||||
|
||||
@@ -44,7 +45,7 @@ class ContentDisposition implements Arrayable, JsonSerializable
|
||||
}
|
||||
|
||||
$parameters = isset($innerTokens[1]) && $innerTokens[1] instanceof ListData
|
||||
? $innerTokens[1]->toKeyValuePairs()
|
||||
? MimeParameterParser::parse($innerTokens[1]->toKeyValuePairs())
|
||||
: [];
|
||||
|
||||
return new self($type, $parameters);
|
||||
@@ -82,7 +83,7 @@ class ContentDisposition implements Arrayable, JsonSerializable
|
||||
*/
|
||||
public function filename(): ?string
|
||||
{
|
||||
return $this->parameters['filename'] ?? null;
|
||||
return $this->parameter('filename');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
59
libs/vendor/directorytree/imapengine/src/Support/MimeParameterParser.php
vendored
Normal file
59
libs/vendor/directorytree/imapengine/src/Support/MimeParameterParser.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace DirectoryTree\ImapEngine\Support;
|
||||
|
||||
use ZBateson\MailMimeParser\Header\ParameterHeader;
|
||||
|
||||
class MimeParameterParser
|
||||
{
|
||||
/**
|
||||
* Parse and normalize MIME parameters.
|
||||
*
|
||||
* @param array<string, string> $parameters
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function parse(array $parameters): array
|
||||
{
|
||||
if (empty($parameters)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$header = new ParameterHeader(
|
||||
'Content-Type',
|
||||
'application/octet-stream; '.implode('; ', static::stringify($parameters))
|
||||
);
|
||||
|
||||
$parsed = [];
|
||||
|
||||
foreach (array_keys($parameters) as $name) {
|
||||
$name = strtolower(explode('*', $name, 2)[0]);
|
||||
|
||||
if (array_key_exists($name, $parsed)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_null($value = $header->getValueFor($name))) {
|
||||
$parsed[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert parameter values into MIME parameter syntax.
|
||||
*
|
||||
* @param array<string, string> $parameters
|
||||
* @return string[]
|
||||
*/
|
||||
protected static function stringify(array $parameters): array
|
||||
{
|
||||
$values = [];
|
||||
|
||||
foreach ($parameters as $name => $value) {
|
||||
$values[] = sprintf('%s="%s"', $name, Str::escape($value));
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
@@ -300,6 +300,10 @@ class Str
|
||||
*/
|
||||
public static function decodeMimeHeader(string $value): string
|
||||
{
|
||||
if (empty($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (! str_contains($value, '=?')) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user