Skip to content

Commit

Permalink
Prevent infinite loop in ImapProtocol (#316)
Browse files Browse the repository at this point in the history
* Prevent infinite loop in ImapProtocol

* Fix PHP TypeError
  • Loading branch information
thin-k-design committed Mar 1, 2023
1 parent e108c27 commit 56c2c51
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Connection/Protocols/ImapProtocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected function enableStartTls() {
*/
public function nextLine(Response $response): string {
$line = "";
while (($next_char = fread($this->stream, 1)) !== false && $next_char !== "\n") {
while (($next_char = fread($this->stream, 1)) !== false && !in_array($next_char, ["","\n"])) {
$line .= $next_char;
}
if ($line === "" && $next_char === false) {
Expand Down Expand Up @@ -147,7 +147,7 @@ protected function nextTaggedLine(Response $response, ?string &$tag): string {
$line = $this->nextLine($response);
list($tag, $line) = explode(' ', $line, 2);

return $line;
return $line ?? '';
}

/**
Expand Down

0 comments on commit 56c2c51

Please sign in to comment.