diff --git a/composer.json b/composer.json index c82f2281..32595e2a 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "sort-packages": true }, "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0 <8.1", "ext-fileinfo": "*", "ext-iconv": "*", "ext-imap": "*", diff --git a/src/PhpImap/DataPartInfo.php b/src/PhpImap/DataPartInfo.php index 173d1e59..b02c1c94 100644 --- a/src/PhpImap/DataPartInfo.php +++ b/src/PhpImap/DataPartInfo.php @@ -109,8 +109,7 @@ protected function convertEncodingAfterFetch(): string { if (isset($this->charset) and !empty(\trim($this->charset))) { $this->data = $this->mail->decodeMimeStr( - (string) $this->data, // Data to convert - (string) \trim($this->charset) + (string) $this->data // Data to convert ); } diff --git a/src/PhpImap/Mailbox.php b/src/PhpImap/Mailbox.php index 7f58a74e..a3e47d74 100644 --- a/src/PhpImap/Mailbox.php +++ b/src/PhpImap/Mailbox.php @@ -1332,7 +1332,6 @@ public function downloadAttachment(DataPartInfo $dataInfo, array $params, object * Decodes a mime string. * * @param string $string MIME string to decode - * @param string|null $charsetPreferred The charset of the data part info if it was set * * @return string Converted string if conversion was successful, or the original string if not * @@ -1340,7 +1339,7 @@ public function downloadAttachment(DataPartInfo $dataInfo, array $params, object * * @todo update implementation pending resolution of https://github.com/vimeo/psalm/issues/2619 & https://github.com/vimeo/psalm/issues/2620 */ - public function decodeMimeStr(string $string, ?string $charsetPreferred = null): string + public function decodeMimeStr(string $string): string { $newString = ''; /** @var list|false */ @@ -1354,7 +1353,7 @@ public function decodeMimeStr(string $string, ?string $charsetPreferred = null): $charset = \strtolower($element->charset); if ('default' === $charset) { - $charset = !empty($charsetPreferred) ? $charsetPreferred : $this->decodeMimeStrDefaultCharset; + $charset = $this->decodeMimeStrDefaultCharset; } switch ($charset) {