upgrade to laravel 8.0

This commit is contained in:
Attila Kerekes
2022-11-13 17:05:03 +01:00
committed by Attila Jozsef Kerekes
parent 43f894b58d
commit 27f58c0866
3895 changed files with 150576 additions and 124482 deletions

View File

@@ -81,17 +81,17 @@ final class CharacterStream
$this->fixedWidth = 2;
break;
// 32 bits
// 32 bits
case 'ucs4':
case 'ucs-4':
case 'utf32':
case 'utf-32':
$this->fixedWidth = 4;
break;
break;
// 7-8 bit charsets: (us-)?ascii, (iso|iec)-?8859-?[0-9]+, windows-?125[0-9], cp-?[0-9]+, ansi, macintosh,
// 7-8 bit charsets: (us-)?ascii, (iso|iec)-?8859-?[0-9]+, windows-?125[0-9], cp-?[0-9]+, ansi, macintosh,
// koi-?7, koi-?8-?.+, mik, (cork|t1), v?iscii
// and fallback
// and fallback
default:
$this->fixedWidth = 1;
}

View File

@@ -43,6 +43,10 @@ class Email extends Message
private $html;
private $htmlCharset;
private $attachments = [];
/**
* @var AbstractPart|null
*/
private $cachedBody; // Used to avoid wrong body hash in DKIM signatures with multiple parts (e.g. HTML + TEXT) due to multiple boundaries.
/**
* @return $this
@@ -282,6 +286,7 @@ class Email extends Message
throw new \TypeError(sprintf('The body must be a string, a resource or null (got "%s").', get_debug_type($body)));
}
$this->cachedBody = null;
$this->text = $body;
$this->textCharset = $charset;
@@ -312,6 +317,7 @@ class Email extends Message
throw new \TypeError(sprintf('The body must be a string, a resource or null (got "%s").', get_debug_type($body)));
}
$this->cachedBody = null;
$this->html = $body;
$this->htmlCharset = $charset;
@@ -342,6 +348,7 @@ class Email extends Message
throw new \TypeError(sprintf('The body must be a string or a resource (got "%s").', get_debug_type($body)));
}
$this->cachedBody = null;
$this->attachments[] = ['body' => $body, 'name' => $name, 'content-type' => $contentType, 'inline' => false];
return $this;
@@ -352,6 +359,7 @@ class Email extends Message
*/
public function attachFromPath(string $path, string $name = null, string $contentType = null)
{
$this->cachedBody = null;
$this->attachments[] = ['path' => $path, 'name' => $name, 'content-type' => $contentType, 'inline' => false];
return $this;
@@ -368,6 +376,7 @@ class Email extends Message
throw new \TypeError(sprintf('The body must be a string or a resource (got "%s").', get_debug_type($body)));
}
$this->cachedBody = null;
$this->attachments[] = ['body' => $body, 'name' => $name, 'content-type' => $contentType, 'inline' => true];
return $this;
@@ -378,6 +387,7 @@ class Email extends Message
*/
public function embedFromPath(string $path, string $name = null, string $contentType = null)
{
$this->cachedBody = null;
$this->attachments[] = ['path' => $path, 'name' => $name, 'content-type' => $contentType, 'inline' => true];
return $this;
@@ -388,6 +398,7 @@ class Email extends Message
*/
public function attachPart(DataPart $part)
{
$this->cachedBody = null;
$this->attachments[] = ['part' => $part];
return $this;
@@ -446,9 +457,13 @@ class Email extends Message
*/
private function generateBody(): AbstractPart
{
if (null !== $this->cachedBody) {
return $this->cachedBody;
}
$this->ensureValidity();
[$htmlPart, $attachmentParts, $inlineParts] = $this->prepareParts();
[$htmlPart, $otherParts, $relatedParts] = $this->prepareParts();
$part = null === $this->text ? null : new TextPart($this->text, $this->textCharset);
if (null !== $htmlPart) {
@@ -459,19 +474,19 @@ class Email extends Message
}
}
if ($inlineParts) {
$part = new RelatedPart($part, ...$inlineParts);
if ($relatedParts) {
$part = new RelatedPart($part, ...$relatedParts);
}
if ($attachmentParts) {
if ($otherParts) {
if ($part) {
$part = new MixedPart($part, ...$attachmentParts);
$part = new MixedPart($part, ...$otherParts);
} else {
$part = new MixedPart(...$attachmentParts);
$part = new MixedPart(...$otherParts);
}
}
return $part;
return $this->cachedBody = $part;
}
private function prepareParts(): ?array
@@ -482,35 +497,49 @@ class Email extends Message
if (null !== $html) {
$htmlPart = new TextPart($html, $this->htmlCharset, 'html');
$html = $htmlPart->getBody();
preg_match_all('(<img\s+[^>]*src\s*=\s*(?:([\'"])cid:([^"]+)\\1|cid:([^>\s]+)))i', $html, $names);
preg_match_all('(<img\s+[^>]*src\s*=\s*(?:([\'"])cid:(.+?)\\1|cid:([^>\s]+)))i', $html, $names);
$names = array_filter(array_unique(array_merge($names[2], $names[3])));
}
$attachmentParts = $inlineParts = [];
// usage of reflection is a temporary workaround for missing getters that will be added in 6.2
$nameRef = new \ReflectionProperty(TextPart::class, 'name');
$nameRef->setAccessible(true);
$otherParts = $relatedParts = [];
foreach ($this->attachments as $attachment) {
$part = $this->createDataPart($attachment);
if (isset($attachment['part'])) {
$attachment['name'] = $nameRef->getValue($part);
}
$related = false;
foreach ($names as $name) {
if (isset($attachment['part'])) {
continue;
}
if ($name !== $attachment['name']) {
continue;
}
if (isset($inlineParts[$name])) {
if (isset($relatedParts[$name])) {
continue 2;
}
$attachment['inline'] = true;
$inlineParts[$name] = $part = $this->createDataPart($attachment);
$html = str_replace('cid:'.$name, 'cid:'.$part->getContentId(), $html);
$part->setDisposition('inline');
$html = str_replace('cid:'.$name, 'cid:'.$part->getContentId(), $html, $count);
if ($count) {
$related = true;
}
$part->setName($part->getContentId());
continue 2;
break;
}
if ($related) {
$relatedParts[$attachment['name']] = $part;
} else {
$otherParts[] = $part;
}
$attachmentParts[] = $this->createDataPart($attachment);
}
if (null !== $htmlPart) {
$htmlPart = new TextPart($html, $this->htmlCharset, 'html');
}
return [$htmlPart, $attachmentParts, array_values($inlineParts)];
return [$htmlPart, $otherParts, array_values($relatedParts)];
}
private function createDataPart(array $attachment): DataPart

View File

@@ -109,6 +109,11 @@ abstract class AbstractHeader implements HeaderInterface
}
$phraseStr = $this->encodeWords($header, $string, $usedLength);
}
} elseif (str_contains($phraseStr, '(')) {
foreach (['\\', '"'] as $char) {
$phraseStr = str_replace($char, '\\'.$char, $phraseStr);
}
$phraseStr = '"'.$phraseStr.'"';
}
return $phraseStr;
@@ -195,7 +200,7 @@ abstract class AbstractHeader implements HeaderInterface
$encodingWrapperLength = \strlen('=?'.$charsetDecl.'?'.self::$encoder->getName().'??=');
if ($firstLineOffset >= 75) {
//Does this logic need to be here?
// Does this logic need to be here?
$firstLineOffset = 0;
}

View File

@@ -83,7 +83,7 @@ final class MessageConverter
2 === \count($parts) &&
$parts[0] instanceof TextPart && 'text' === $parts[0]->getMediaType() && 'plain' === $parts[0]->getMediaSubtype() &&
$parts[1] instanceof TextPart && 'text' === $parts[1]->getMediaType() && 'html' === $parts[1]->getMediaSubtype()
) {
) {
return (new Email(clone $message->getHeaders()))
->text($parts[0]->getBody(), $parts[0]->getPreparedHeaders()->getHeaderParameter('Content-Type', 'charset') ?: 'utf-8')
->html($parts[1]->getBody(), $parts[1]->getPreparedHeaders()->getHeaderParameter('Content-Type', 'charset') ?: 'utf-8')

View File

@@ -197,6 +197,7 @@ class TextPart extends AbstractPart
// convert resources to strings for serialization
if (null !== $this->seekable) {
$this->body = $this->getBody();
$this->seekable = null;
}
$this->_headers = $this->getHeaders();

View File

@@ -9,6 +9,10 @@
* file that was distributed with this source code.
*/
if ('cli' !== \PHP_SAPI) {
throw new Exception('This script must be run from the command line.');
}
// load new map
$data = json_decode(file_get_contents('https://cdn.jsdelivr.net/gh/jshttp/mime-db@v1.49.0/db.json'), true);
$new = [];

View File

@@ -28,13 +28,14 @@
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
"symfony/property-access": "^4.4|^5.1|^6.0",
"symfony/property-info": "^4.4|^5.1|^6.0",
"symfony/serializer": "^5.2|^6.0"
"symfony/serializer": "^5.4.14|~6.0.14|^6.1.6"
},
"conflict": {
"egulias/email-validator": "~3.0.0",
"phpdocumentor/reflection-docblock": "<3.2.2",
"phpdocumentor/type-resolver": "<1.4.0",
"symfony/mailer": "<4.4"
"symfony/mailer": "<4.4",
"symfony/serializer": "<5.4.14|>=6.0,<6.0.14|>=6.1,<6.1.6"
},
"autoload": {
"psr-4": { "Symfony\\Component\\Mime\\": "" },