[Web] Update libs

This commit is contained in:
andryyy
2021-01-04 11:11:04 +01:00
parent 46928269bb
commit ee6989bd1d
84 changed files with 3264 additions and 931 deletions

View File

@@ -228,6 +228,7 @@ final class Connection implements ConnectionInterface
foreach ($mailboxesInfo as $mailboxInfo) {
$name = \mb_convert_encoding(\str_replace($this->server, '', $mailboxInfo->name), 'UTF-8', 'UTF7-IMAP');
\assert(\is_string($name));
$this->mailboxNames[$name] = $mailboxInfo;
}
}

View File

@@ -154,6 +154,10 @@ final class Mailbox implements MailboxInterface
}
$query = $search->toString();
if (\PHP_VERSION_ID < 80000) {
$descending = (int) $descending;
}
// We need to clear the stack to know whether imap_last_error()
// is related to this imap_search
\imap_errors();
@@ -162,7 +166,7 @@ final class Mailbox implements MailboxInterface
$params = [
$this->resource->getStream(),
$sortCriteria,
$descending ? 1 : 0,
$descending,
\SE_UID,
$query,
];
@@ -181,11 +185,13 @@ final class Mailbox implements MailboxInterface
}
$messageNumbers = \imap_search(...$params);
}
if (false !== \imap_last_error()) {
// this way all errors occurred during search will be reported
throw new InvalidSearchCriteriaException(
\sprintf('Invalid search criteria [%s]', $query)
);
}
if (false === $messageNumbers) {
if (false !== \imap_last_error()) {
throw new InvalidSearchCriteriaException(\sprintf('Invalid search criteria [%s]', $query));
}
// imap_search can also return false
$messageNumbers = [];
}
@@ -203,13 +209,14 @@ final class Mailbox implements MailboxInterface
\imap_errors();
$overview = \imap_fetch_overview($this->resource->getStream(), $sequence, \FT_UID);
if (false !== \imap_last_error()) {
throw new InvalidSearchCriteriaException(
\sprintf('Invalid sequence [%s]', $sequence)
);
}
if (\is_array($overview) && [] !== $overview) {
$messageNumbers = \array_column($overview, 'uid');
} else {
if (false !== \imap_last_error()) {
throw new InvalidSearchCriteriaException(\sprintf('Invalid sequence [%s]', $sequence));
}
$messageNumbers = [];
}
@@ -264,7 +271,7 @@ final class Mailbox implements MailboxInterface
});
/** @var array|false $tree */
$tree = \imap_thread($this->resource->getStream());
$tree = \imap_thread($this->resource->getStream(), \SE_UID);
\restore_error_handler();

View File

@@ -109,7 +109,15 @@ final class Message extends Message\AbstractMessage implements MessageInterface
}
$this->messageNumberVerified = true;
$msgno = null;
\set_error_handler(static function (): bool {
return true;
});
$msgno = \imap_msgno($this->resource->getStream(), $messageNumber);
\restore_error_handler();
if (\is_numeric($msgno) && $msgno > 0) {
$this->imapMsgNo = $msgno;
@@ -306,7 +314,7 @@ final class Message extends Message\AbstractMessage implements MessageInterface
// 'deleted' header changed, force to reload headers, would be better to set deleted flag to true on header
$this->clearHeaders();
if (!\imap_delete($this->resource->getStream(), $this->getNumber(), \FT_UID)) {
if (!\imap_delete($this->resource->getStream(), (string) $this->getNumber(), \FT_UID)) {
throw new MessageDeleteException(\sprintf('Message "%s" cannot be deleted', $this->getNumber()));
}
}
@@ -320,7 +328,7 @@ final class Message extends Message\AbstractMessage implements MessageInterface
{
// 'deleted' header changed, force to reload headers, would be better to set deleted flag to false on header
$this->clearHeaders();
if (!\imap_undelete($this->resource->getStream(), $this->getNumber(), \FT_UID)) {
if (!\imap_undelete($this->resource->getStream(), (string) $this->getNumber(), \FT_UID)) {
throw new MessageUndeleteException(\sprintf('Message "%s" cannot be undeleted', $this->getNumber()));
}
}

View File

@@ -113,6 +113,7 @@ abstract class AbstractMessage extends AbstractPart
$alteredValue = \str_replace(',', '', $alteredValue);
$alteredValue = (string) \preg_replace('/^[a-zA-Z]+ ?/', '', $alteredValue);
$alteredValue = (string) \preg_replace('/\(.*\)/', '', $alteredValue);
$alteredValue = (string) \preg_replace('/\<.*\>/', '', $alteredValue);
$alteredValue = (string) \preg_replace('/\bUT\b/', 'UTC', $alteredValue);
if (0 === \preg_match('/\d\d:\d\d:\d\d.* [\+\-]\d\d:?\d\d/', $alteredValue)) {
$alteredValue .= ' +0000';

View File

@@ -471,9 +471,11 @@ abstract class AbstractPart implements PartInterface
$this->type = self::$typesMap[$this->structure->type] ?? self::TYPE_UNKNOWN;
// In our context, \ENCOTHER is as useful as an uknown encoding
// In our context, \ENCOTHER is as useful as an unknown encoding
$this->encoding = self::$encodingsMap[$this->structure->encoding] ?? self::ENCODING_UNKNOWN;
$this->subtype = $this->structure->subtype;
if (isset($this->structure->subtype)) {
$this->subtype = $this->structure->subtype;
}
if (isset($this->structure->bytes)) {
$this->bytes = $this->structure->bytes;

View File

@@ -310,7 +310,13 @@ final class Transcoder
return true;
});
$decodedText = \mb_convert_encoding($text, 'UTF-8', $fromCharset);
$decodedText = '';
try {
$decodedText = \mb_convert_encoding($text, 'UTF-8', $fromCharset);
} catch (\Error $error) {
$errorMessage = $error->getMessage();
}
\restore_error_handler();