diff -urN ../z-push-2.6.2+0.orig/src/include/mimeDecode.php ./src/include/mimeDecode.php --- ../z-push-2.6.2+0.orig/src/include/mimeDecode.php 2023-03-18 01:57:07.838734000 +0200 +++ ./src/include/mimeDecode.php 2023-06-11 21:13:40.017219000 +0300 @@ -874,8 +874,14 @@ break; } - if ($detectCharset && strtolower($charset) != $this->_charset) { - if (@mb_check_encoding($input, $charset) == false) { + if ($detectCharset && $charset && strtolower($charset) != $this->_charset) { + $encoding_valid = true; + try { + mb_check_encoding("", $charset); + } catch (Throwable $e) { + $encoding_valid = false; + } + if (!$encoding_valid or (@mb_check_encoding($input, $charset) == false)) { // list of encodings, sorted by priority to assist mb_detect_encoding() $encodingPriority = array('UTF-8', 'SJIS', 'GB18030', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', 'ISO-8859-10', 'ISO-8859-13',