Skip to content

Commit 7d9a886

Browse files
committed
Fix parsing response with multiple BODY responses
1 parent ff5e0d2 commit 7d9a886

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/Connection/ImapParser.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,14 @@ protected function parseBracketGroup(): ResponseCodeData
173173
while (
174174
$this->currentToken
175175
&& ! $this->currentToken instanceof ResponseCodeClose
176-
&& ! $this->isEndOfResponseToken($this->currentToken)
177176
) {
177+
// Skip CRLF tokens that may appear inside bracket groups.
178+
if ($this->currentToken instanceof Crlf) {
179+
$this->advance();
180+
181+
continue;
182+
}
183+
178184
$elements[] = $this->parseElement();
179185
}
180186

@@ -204,8 +210,14 @@ protected function parseList(): ListData
204210
while (
205211
$this->currentToken
206212
&& ! $this->currentToken instanceof ListClose
207-
&& ! $this->isEndOfResponseToken($this->currentToken)
208213
) {
214+
// Skip CRLF tokens that appear inside lists (after literals).
215+
if ($this->currentToken instanceof Crlf) {
216+
$this->advance();
217+
218+
continue;
219+
}
220+
209221
$elements[] = $this->parseElement();
210222
}
211223

0 commit comments

Comments
 (0)