[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

@@ -1,5 +1,46 @@
# Changelog
## [1.11.0](https://github.com/ddeboer/imap/tree/1.11.0) (2020-11-30)
[Full Changelog](https://github.com/ddeboer/imap/compare/1.10.1...1.11.0)
**Implemented enhancements:**
- PHP 8 Compatibility [\#481](https://github.com/ddeboer/imap/issues/481)
- \[GA\] PHP 8 compatibility fix [\#483](https://github.com/ddeboer/imap/pull/483) ([Slamdunk](https://github.com/Slamdunk))
- Support PHP 8.0, require PHP 7.3 [\#482](https://github.com/ddeboer/imap/pull/482) ([Slamdunk](https://github.com/Slamdunk))
**Fixed bugs:**
- Fix: Outlook date format [\#480](https://github.com/ddeboer/imap/pull/480) ([gajosadrian](https://github.com/gajosadrian))
**Closed issues:**
- Closing Connection [\#479](https://github.com/ddeboer/imap/issues/479)
- Problem with charset of message part / DataPartInfo [\#475](https://github.com/ddeboer/imap/issues/475)
- Unsupported charset "X-UNKNOWN" [\#425](https://github.com/ddeboer/imap/issues/425)
## [1.10.1](https://github.com/ddeboer/imap/tree/1.10.1) (2020-08-26)
[Full Changelog](https://github.com/ddeboer/imap/compare/1.10.0...1.10.1)
**Fixed bugs:**
- getThread and getMessageSequence not using with the same id [\#469](https://github.com/ddeboer/imap/issues/469)
- imap\_thread: use absolude ids [\#474](https://github.com/ddeboer/imap/pull/474) ([Slamdunk](https://github.com/Slamdunk))
**Closed issues:**
- How to get a message by Message-ID [\#472](https://github.com/ddeboer/imap/issues/472)
- Mail with e-sign [\#467](https://github.com/ddeboer/imap/issues/467)
- Duplicate method definition in MessageInterface [\#455](https://github.com/ddeboer/imap/issues/455)
- Missed errors in search method [\#444](https://github.com/ddeboer/imap/issues/444)
**Merged pull requests:**
- Subtype not always present [\#473](https://github.com/ddeboer/imap/pull/473) ([Piskvor](https://github.com/Piskvor))
- Improved error handling for message search method [\#445](https://github.com/ddeboer/imap/pull/445) ([ikarol](https://github.com/ikarol))
## [1.10.0](https://github.com/ddeboer/imap/tree/1.10.0) (2020-01-24)
[Full Changelog](https://github.com/ddeboer/imap/compare/1.9.0...1.10.0)

View File

@@ -1,12 +1,11 @@
# IMAP library
[![Build Status](https://travis-ci.org/ddeboer/imap.svg?branch=master)](https://travis-ci.org/ddeboer/imap)
[![Code Coverage](https://scrutinizer-ci.com/g/ddeboer/imap/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/ddeboer/imap/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ddeboer/imap/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ddeboer/imap/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/ddeboer/imap/v/stable.svg)](https://packagist.org/packages/ddeboer/imap)
[![Total Downloads](https://poser.pugx.org/ddeboer/imap/downloads.png)](https://packagist.org/packages/ddeboer/imap)
[![Latest Stable Version](https://img.shields.io/packagist/v/ddeboer/imap.svg)](https://packagist.org/packages/ddeboer/imap)
[![Downloads](https://img.shields.io/packagist/dt/ddeboer/imap.svg)](https://packagist.org/packages/ddeboer/imap)
[![Integrate](https://github.com/ddeboer/imap/workflows/Integrate/badge.svg?branch=master)](https://github.com/ddeboer/imap/actions)
[![Code Coverage](https://codecov.io/gh/ddeboer/imap/coverage.svg?branch=master)](https://codecov.io/gh/ddeboer/imap?branch=master)
A PHP 7.2+ library to read and process e-mails over IMAP.
A PHP 7.3+ library to read and process e-mails over IMAP.
This library requires [IMAP](https://secure.php.net/manual/en/book.imap.php),
[iconv](https://secure.php.net/manual/en/book.iconv.php) and

View File

@@ -22,18 +22,23 @@
}
],
"require": {
"php": "^7.2",
"php": "^7.3 || ^8.0",
"ext-iconv": "*",
"ext-imap": "*",
"ext-mbstring": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.16",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^8.5",
"zendframework/zend-mail": "^2.10"
"friendsofphp/php-cs-fixer": "^2.16.7",
"laminas/laminas-mail": "^2.12.3",
"phpstan/phpstan": "^0.12.57",
"phpstan/phpstan-phpunit": "^0.12.16",
"phpstan/phpstan-strict-rules": "^0.12.5",
"phpunit/phpunit": "^9.4.3"
},
"config": {
"platform": {
"php": "7.3"
}
},
"autoload": {
"psr-4": {

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();