Attempted workaround for some Google brokenness.
Nicholas Marriott
13 years ago
|
0 |
01 September 2010
|
|
1 |
|
|
2 |
* Detect GMail's XYZZY capability for IMAP and use it to try and workaround
|
|
3 |
some of their broken behaviour (incorrectly reported message sizes).
|
|
4 |
|
0 | 5 |
31 May 2009
|
1 | 6 |
|
2 | 7 |
* Print a warning on missing maildirs when fetching from them rather than
|
169 | 169 |
struct fetch_ctx fctx;
|
170 | 170 |
struct fetch_imap_data fdata;
|
171 | 171 |
char *cause, *folder, *ptr, *line;
|
172 | |
size_t len;
|
|
172 |
size_t len, maillen;
|
173 | 173 |
u_int total, body;
|
174 | 174 |
|
175 | 175 |
/* Connect to the IMAP server. */
|
|
227 | 227 |
goto error;
|
228 | 228 |
}
|
229 | 229 |
|
230 | |
/* Send the mail size, not forgetting lines are CRLF terminated. */
|
|
230 |
/*
|
|
231 |
* Send the mail size, not forgetting lines are CRLF terminated. The
|
|
232 |
* Google IMAP server is written strangely, so send the size as if
|
|
233 |
* every CRLF was a CR if the server has XYZZY.
|
|
234 |
*/
|
231 | 235 |
count_lines(m, &total, &body);
|
232 | |
if (imap_putln(a, "%s {%zu}", folder, m->size + total - 1) != 0)
|
|
236 |
maillen = m->size + total - 1;
|
|
237 |
if (fdata.capa & IMAP_CAPA_XYZZY) {
|
|
238 |
log_debug2("%s: adjusting size: actual %zu", a->name, maillen);
|
|
239 |
maillen = m->size;
|
|
240 |
}
|
|
241 |
if (imap_putln(a, "%s {%zu}", folder, maillen) != 0)
|
233 | 242 |
goto error;
|
234 | 243 |
switch (deliver_imap_waitappend(a, &fctx, io, &line)) {
|
235 | 244 |
case IMAP_TAG_ERROR:
|
60 | 60 |
int imap_state_close(struct account *, struct fetch_ctx *);
|
61 | 61 |
int imap_state_quit(struct account *, struct fetch_ctx *);
|
62 | 62 |
|
63 | |
#define IMAP_CAPA_AUTH_CRAM_MD5 0x1
|
64 | |
|
65 | 63 |
/* Put line to server. */
|
66 | 64 |
int
|
67 | 65 |
imap_putln(struct account *a, const char *fmt, ...)
|
|
368 | 366 |
if (strstr(line, "AUTH=CRAM-MD5") != NULL)
|
369 | 367 |
data->capa |= IMAP_CAPA_AUTH_CRAM_MD5;
|
370 | 368 |
|
|
369 |
/* Use XYZZY to detect Google brokenness. */
|
|
370 |
if (strstr(line, "XYZZY") != NULL)
|
|
371 |
data->capa |= IMAP_CAPA_XYZZY;
|
|
372 |
|
371 | 373 |
fctx->state = imap_state_capability2;
|
372 | 374 |
return (FETCH_AGAIN);
|
373 | 375 |
}
|