diff --git a/app/Console/Commands/TestWebklex.php b/app/Console/Commands/TestWebklex.php index 932f3860a..5fbadcd44 100644 --- a/app/Console/Commands/TestWebklex.php +++ b/app/Console/Commands/TestWebklex.php @@ -87,7 +87,7 @@ public function handle() $this->line('In-Reply-To: '); $this->info($message->getInReplyTo()); $this->line('References: '); - $this->info(json_encode(array_values(array_filter(preg_split('/[, <>]/', $message->getReferences() ?? []))), JSON_UNESCAPED_UNICODE)); + $this->info(json_encode(array_values(array_filter(preg_split('/[, <>]/', $message->getReferences() ?? ''))), JSON_UNESCAPED_UNICODE)); $this->line('Subject: '); $this->info($message->getSubject()); $this->line('Text Body: '); diff --git a/overrides/webklex/php-imap/src/Message.php b/overrides/webklex/php-imap/src/Message.php index 6fc5de377..58c9d64c3 100644 --- a/overrides/webklex/php-imap/src/Message.php +++ b/overrides/webklex/php-imap/src/Message.php @@ -722,13 +722,16 @@ public function convertEncoding($str, string $from = "ISO-8859-2", string $to = if (strtolower($from ?? '') == 'us-ascii' && $to == 'UTF-8') { return $str; } + if (!$str) { + return $str; + } $result = ''; if (strtolower($from) == 'iso-2022-jp'){ $from = 'iso-2022-jp-ms'; } - + // Try iconv. if (function_exists('iconv') && $from != 'UTF-7' && $to != 'UTF-7' && $from != 'iso-2022-jp-ms') { try { @@ -742,7 +745,7 @@ public function convertEncoding($str, string $from = "ISO-8859-2", string $to = // Detected an illegal character in input string. // https://github.com/freescout-helpdesk/freescout/issues/3089 - // Use try...catch to avoid: + // Use try...catch to avoid // mb_convert_encoding(): Argument #3 ($from_encoding) contains invalid encoding "windows-1257" // https://github.com/freescout-helpdesk/freescout/issues/4051 try { @@ -754,7 +757,7 @@ public function convertEncoding($str, string $from = "ISO-8859-2", string $to = } else { return $result; } - } catch (\Exception $e) { + } catch (\Throwable $e) { return $str; } }