Bump imapengine from 1.25.4 to 1.25.6 and dependencies

This commit is contained in:
johnnyq
2026-08-26 13:02:29 -04:00
parent 71cfdf5e39
commit 3d9a41bec4
54 changed files with 978 additions and 543 deletions

View File

@@ -54,7 +54,7 @@ final class Address
throw new InvalidArgumentException('Email address contains control characters.');
}
if (!self::$validator->isValid($this->address, class_exists(MessageIDValidation::class) ? new MessageIDValidation() : new RFCValidation())) {
if (!self::isValidAddrSpec($this->address)) {
throw new RfcComplianceException(\sprintf('Email "%s" does not comply with addr-spec of RFC 2822.', $address));
}
}
@@ -87,7 +87,7 @@ final class Address
return '';
}
return \sprintf('"%s"', preg_replace('/"/u', '\"', $this->getName()));
return \sprintf('"%s"', preg_replace('/["\\\\]/', '\\\\$0', $this->getName()));
}
public static function create(self|string $address): self
@@ -141,4 +141,19 @@ final class Address
{
return (bool) preg_match('/[\x80-\xFF].*@/', $this->address);
}
private static function isValidAddrSpec(string $address): bool
{
// the message id validation is needed as this class also holds the ids of the Message-ID,
// In-Reply-To and References headers, but it accepts an unquoted "@" in the local part
if (!self::$validator->isValid($address, class_exists(MessageIDValidation::class) ? new MessageIDValidation() : new RFCValidation())) {
return false;
}
if (substr_count($address, '@') < 2) {
return true;
}
return self::$validator->isValid(substr($address, 0, strrpos($address, '@')).'@example.com', new RFCValidation());
}
}

View File

@@ -482,6 +482,7 @@ class Email extends Message
}
$otherParts = $relatedParts = [];
$cidReplacements = [];
foreach ($this->attachments as $part) {
foreach ($names as $name) {
if ($name !== $part->getName() && (!$part->hasContentId() || $name !== $part->getContentId())) {
@@ -491,9 +492,7 @@ class Email extends Message
continue 2;
}
if ($name !== $part->getContentId()) {
$html = str_replace('cid:'.$name, 'cid:'.$part->getContentId(), $html);
}
$cidReplacements['cid:'.$name] = 'cid:'.$part->getContentId();
$relatedParts[$name] = $part;
$part->setName($part->getName() ?? $part->getContentId())->asInline();
@@ -502,6 +501,11 @@ class Email extends Message
$otherParts[] = $part;
}
if ($cidReplacements) {
// all references are replaced at once as strtr() matches the longest name first and
// never replaces inside already substituted text, unlike successive str_replace() calls
$html = strtr($html, $cidReplacements);
}
if (null !== $htmlPart) {
$htmlPart = new TextPart($html, $this->htmlCharset, 'html');
}

View File

@@ -169,7 +169,7 @@ final class Headers
$header->setMaxLineLength($this->lineLength);
$name = strtolower($header->getName());
if (\in_array($name, self::UNIQUE_HEADERS, true) && isset($this->headers[$name]) && \count($this->headers[$name]) > 0) {
if (\in_array($name, self::UNIQUE_HEADERS, true) && isset($this->headers[$name]) && $this->headers[$name]) {
throw new LogicException(\sprintf('Impossible to set header "%s" as it\'s already defined and must be unique.', $header->getName()));
}

View File

@@ -67,7 +67,7 @@ class RawMessage
if (\is_resource($this->message)) {
rewind($this->message);
while ($line = fgets($this->message)) {
while (false !== $line = fgets($this->message)) {
yield $line;
}

View File

@@ -29,7 +29,7 @@
"symfony/process": "^6.4|^7.0|^8.0",
"symfony/property-access": "^6.4|^7.0|^8.0",
"symfony/property-info": "^6.4|^7.0|^8.0",
"symfony/serializer": "^6.4.3|^7.0.3|^8.0"
"symfony/serializer": "^6.4.44|^7.4.17|^8.1.5"
},
"conflict": {
"egulias/email-validator": "~3.0.0",