[Evolution-hackers] [PATCH evolution-data-server] imapx: Treat BODY[HEADER] as equivalent to RFC822.HEADER



A broken IMAP server (whatever they use at Masaryk University) was seen
having this conversation:

[imapx:A] camel_imapx_write: 'A00666 UID FETCH 1:* (RFC822.SIZE RFC822.HEADER FLAGS)
...
[imapx:A] camel_imapx_read: buffer is '* 1 FETCH (RFC822.SIZE 4220 BODY[HEADER] {523}
...

This confuses evolution into thinking that it was a request for a full message
and it in turns fails to update message list (the mailbox seems empty) and
issues a warning about not being able to locate an appropriate FETCH job.

This patch works around the issue by treating BODY[HEADER] as equivalent to
RFC822.HEADER, so I can read my school mail and not be late with assignments.

Signed-off-by: Lubomir Rintel <lkundrak v3 sk>
Cc: Matthew Barnes <mbarnes redhat com>
Cc: Milan Crha <mcrha redhat com>
---
I've not been able to test with master, as it does not seem to cope well with 
the namespace handling (e.g. the response with NIL separator "* NAMESPACE (("" 
NIL)) NIL NIL" hits an assertion, etc.) and therefore I can't access my mailbox 
at all. I suspect that whichever server they use at MUNI (probably some 
commercial one?) is a bit broken. It used to work with the old IMAP backend quite
reliably though. I'll follow up on that as time will permit.

Successfully tested with 3.10 and the code this patches did not change much.

Hopefully I'm sending this to the correct list; I've not been able to find an 
address for patch submissions on the source tree or project's web -- probably 
other contributors are a bit smarter.

Thank you!
Lubo

 camel/providers/imapx/camel-imapx-server.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 21fdc1d..3eceaf5 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -1999,6 +1999,16 @@ imapx_untagged_fetch (CamelIMAPXServer *is,
                return FALSE;
        }
 
+       /* Some broken IMAP implementations respond with BODY[HEADER] when
+        * asked for RFC822.HEADER. Switch it over in such case. */
+       if (!(finfo->got & FETCH_HEADER) && finfo->header == NULL &&
+           finfo->got & FETCH_BODY && !g_strcmp0(finfo->section, "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;
-- 
1.8.4.2



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