Skip to content

Commit 56c2c51

Browse files
Prevent infinite loop in ImapProtocol (#316)
* Prevent infinite loop in ImapProtocol * Fix PHP TypeError
1 parent e108c27 commit 56c2c51

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Connection/Protocols/ImapProtocol.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected function enableStartTls() {
112112
*/
113113
public function nextLine(Response $response): string {
114114
$line = "";
115-
while (($next_char = fread($this->stream, 1)) !== false && $next_char !== "\n") {
115+
while (($next_char = fread($this->stream, 1)) !== false && !in_array($next_char, ["","\n"])) {
116116
$line .= $next_char;
117117
}
118118
if ($line === "" && $next_char === false) {
@@ -147,7 +147,7 @@ protected function nextTaggedLine(Response $response, ?string &$tag): string {
147147
$line = $this->nextLine($response);
148148
list($tag, $line) = explode(' ', $line, 2);
149149

150-
return $line;
150+
return $line ?? '';
151151
}
152152

153153
/**

0 commit comments

Comments
 (0)