aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Kandaurov <pluknet@nginx.com>2024-10-24 00:52:21 +0400
committerpluknet <pluknet@nginx.com>2024-11-26 19:07:17 +0400
commitce88b171236de50843dba2c427a8b3e42778f2ca (patch)
tree5d5c9b1a14ae93ade7ac6149650d3ac998e26e01
parentb2a67d261496555a46b8931935bf822ce9938294 (diff)
downloadnginx-ce88b171236de50843dba2c427a8b3e42778f2ca.tar.gz
nginx-ce88b171236de50843dba2c427a8b3e42778f2ca.zip
Mail: handling of LOGIN IMAP command untagged response.
In particular, an untagged CAPABILITY response as described in the interim RFC 3501 internet drafts was seen in various IMAP servers. Previously resulted in a broken connection, now an untagged response is proxied to client.
-rw-r--r--src/mail/ngx_mail_proxy_module.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/mail/ngx_mail_proxy_module.c b/src/mail/ngx_mail_proxy_module.c
index efed9ab3e..1c6d0372e 100644
--- a/src/mail/ngx_mail_proxy_module.c
+++ b/src/mail/ngx_mail_proxy_module.c
@@ -1019,12 +1019,36 @@ ngx_mail_proxy_read_response(ngx_mail_session_t *s, ngx_uint_t state)
break;
case ngx_imap_passwd:
+
+ /*
+ * untagged CAPABILITY response (draft-crispin-imapv-16),
+ * known to be sent by SmarterMail and Gmail
+ */
+
+ if (p[0] == '*' && p[1] == ' ') {
+ p += 2;
+
+ while (p < b->last - 1) {
+ if (p[0] == CR && p[1] == LF) {
+ p += 2;
+ break;
+ }
+
+ p++;
+ }
+
+ if (b->last - p < 4) {
+ return NGX_AGAIN;
+ }
+ }
+
if (ngx_strncmp(p, s->tag.data, s->tag.len) == 0) {
p += s->tag.len;
if (p[0] == 'O' && p[1] == 'K') {
return NGX_OK;
}
}
+
break;
}