From 6644861f4b616b3e42bc4143109e6b478ca52849 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Sun, 18 Dec 2005 10:34:10 +0000 Subject: Use a simplified version of Sunil's patch to cope with servers such as mail.internode.on.net bld-mail04 that return the UID in response to RFC822.HEADER or RFC822.SIZE. Reported by Jason White. svn path=/branches/BRANCH_6-3/; revision=4555 --- imap.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'imap.c') diff --git a/imap.c b/imap.c index ed5ca59d..b78abb30 100644 --- a/imap.c +++ b/imap.c @@ -875,12 +875,21 @@ static int imap_getpartialsizes(int sock, int first, int last, int *sizes) ; else if (strstr(buf, "OK") || strstr(buf, "NO")) break; - else if (sscanf(buf, "* %u FETCH (RFC822.SIZE %u)", &num, &size) == 2) + else if (sscanf(buf, "* %u FETCH (RFC822.SIZE %u)", &num, &size) == 2 + /* some servers (like mail.internode.on.net bld-mail04) return UID information here + * + * IMAP> A0005 FETCH 1 RFC822.SIZE + * IMAP< * 1 FETCH (UID 16 RFC822.SIZE 1447) + * IMAP< A0005 OK FETCH completed + * + */ + || sscanf(buf, "* %u FETCH (UID %*s RFC822.SIZE %u)", &num, &size) == 2) { if (num >= first && num <= last) - sizes[num - first] = size; + sizes[num - first] = size; else - report(stderr, "Warning: ignoring bogus data for message sizes returned by the server.\n"); + report(stderr, + GT_("Warning: ignoring bogus data for message sizes returned by the server.\n")); } } @@ -948,8 +957,18 @@ static int imap_fetch_headers(int sock, struct query *ctl,int number,int *lenp) if ((ok = gen_recv(sock, buf, sizeof(buf)))) return(ok); ptr = skip_token(buf); /* either "* " or "AXXXX " */ - if (sscanf(ptr, "%d FETCH (%*s {%d}", &num, lenp) == 2) - break; + if (sscanf(ptr, "%d FETCH (RFC822.HEADER {%d}", &num, lenp) == 2 + /* some servers (like mail.internode.on.net bld-mail04) return UID information here + * + * IMAP> A0006 FETCH 1 RFC822.HEADER + * IMAP< * 1 FETCH (UID 16 RFC822.HEADER {1360} + * ... + * IMAP< ) + * IMAP< A0006 OK FETCH completed + * + */ + || sscanf(ptr, "%d FETCH (UID %*s RFC822.HEADER {%d}", &num, lenp) == 2) + break; /* try to recover from chronically fucked-up M$ Exchange servers */ else if (!strncmp(ptr, "NO", 2)) { -- cgit v1.2.3