[evolution-data-server] IMAPX: Handle BODY[HEADER] in FETCH response.



commit 7b0b0de99a2943838b08560f11d7fdf5dac7d422
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Thu Jan 9 12:19:53 2014 -0500

    IMAPX: Handle BODY[HEADER] in FETCH response.
    
    A broken IMAP server (whatever they use at Masaryk University) was
    seen having this conversation:
    
      C: A001 UID FETCH 1:* (RFC822.SIZE RFC822.HEADER FLAGS)
      S: * 1 FETCH (RFC822.SIZE 4220 BODY[HEADER] {523} ...)
      ...
    
    This confuses Camel into thinking it was a request for a full message
    and it in turn fails to update the folder summary and issues a warning
    about not being able to locate an appropriate FETCH job.
    
    This works around the issue by treating BODY[HEADER] as equivalent to
    RFC822.HEADER in untagged FETCH responses.

 camel/providers/imapx/camel-imapx-server.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 8b75c24..2b93e2f 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -1988,6 +1988,7 @@ imapx_untagged_fetch (CamelIMAPXServer *is,
                       GError **error)
 {
        struct _fetch_info *finfo;
+       gboolean got_body_header;
 
        g_return_val_if_fail (CAMEL_IS_IMAPX_SERVER (is), FALSE);
 
@@ -1997,6 +1998,21 @@ imapx_untagged_fetch (CamelIMAPXServer *is,
                return FALSE;
        }
 
+       /* Some IMAP servers respond with BODY[HEADER] when
+        * asked for RFC822.HEADER.  Treat them equivalently. */
+       got_body_header =
+               ((finfo->got & FETCH_HEADER) == 0) &&
+               (finfo->header == NULL) &&
+               ((finfo->got & FETCH_BODY) != 0) &&
+               (g_strcmp0 (finfo->section, "HEADER") == 0);
+
+       if (got_body_header) {
+               finfo->got |= FETCH_HEADER;
+               finfo->got &= ~FETCH_BODY;
+               finfo->header = finfo->body;
+               finfo->body = NULL;
+       }
+
        if ((finfo->got & (FETCH_BODY | FETCH_UID)) == (FETCH_BODY | FETCH_UID)) {
                CamelIMAPXJob *job;
                GetMessageData *data;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]