From 63e2384907798af6faa30ae3200179f02971226e Mon Sep 17 00:00:00 2001 From: FreeScout Date: Wed, 8 Nov 2023 09:21:41 -0800 Subject: [PATCH] PHP IMAP: Only explode the tag line if it contains a space - closes #3503 --- .../php-imap/src/Connection/Protocols/ImapProtocol.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/overrides/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php b/overrides/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php index 0dd96d9a4..98ec9cbfc 100644 --- a/overrides/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php +++ b/overrides/webklex/php-imap/src/Connection/Protocols/ImapProtocol.php @@ -135,7 +135,9 @@ protected function assumedNextLine(string $start): bool { */ protected function nextTaggedLine(&$tag): string { $line = $this->nextLine(); - list($tag, $line) = explode(' ', $line, 2); + if (str_contains($line, ' ')) { + list($tag, $line) = explode(' ', $line, 2); + } return $line ?? ''; } @@ -282,7 +284,7 @@ public function readResponse(string $tag, bool $dontParse = false) { // last line has response code if ($tokens[0] == 'OK') { return $lines ? $lines : true; - } elseif ($tokens[0] == 'NO') { + } elseif ($tokens[0] == 'NO' || $tokens[0] == 'BAD' || $tokens[0] == 'BYE') { return false; }