Commit f438355
authored
imapclient/search: handle UID SEARCH results without hits
When searching for unseen mails we can get the following error if there
are none.
> in response-data: imapwire: expected SP, got "\r"
The reason is that the IMAP server is sending a response like this in
case there are no search hits.
T7 UID SEARCH RETURN (ALL) (UNSEEN)
* ESEARCH (TAG "T7") UID T7 OK SEARCH completed (Success)
The wire protocol parser is expecting a search option (like "ALL") to be
present in any search result. As we can see above, this is not the case
if there are no results, which results in the parser hitting a CRLF when
it expected a space.
To account for this we peek into the reply of the server to see whether
there is a CRLF after the "UID" atom. If there is, we assume there were
no results and return an empty result.1 parent ea10af8 commit f438355
1 file changed
+14
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
280 | | - | |
281 | 280 | | |
282 | 281 | | |
283 | | - | |
| 282 | + | |
284 | 283 | | |
285 | 284 | | |
286 | 285 | | |
| |||
289 | 288 | | |
290 | 289 | | |
291 | 290 | | |
292 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
293 | 294 | | |
294 | 295 | | |
295 | 296 | | |
| 297 | + | |
296 | 298 | | |
297 | | - | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
298 | 302 | | |
299 | 303 | | |
300 | 304 | | |
| 305 | + | |
301 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
302 | 311 | | |
303 | 312 | | |
304 | 313 | | |
| |||
343 | 352 | | |
344 | 353 | | |
345 | 354 | | |
346 | | - | |
347 | | - | |
348 | | - | |
| 355 | + | |
349 | 356 | | |
350 | 357 | | |
351 | 358 | | |
| |||
0 commit comments