dovecot-2.2: imapc: Don't write SEARCH YOUNGER/OLDER queries if ...

dovecot at dovecot.org dovecot at dovecot.org
Thu Apr 23 16:39:00 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/3654b56b6fd2
changeset: 18459:3654b56b6fd2
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Apr 23 19:37:25 2015 +0300
description:
imapc: Don't write SEARCH YOUNGER/OLDER queries if server doesn't support WITHIN extension

diffstat:

 src/lib-imap-client/imapc-client.c         |   1 +
 src/lib-imap-client/imapc-client.h         |   1 +
 src/lib-storage/index/imapc/imapc-search.c |  15 +++++++++++++--
 3 files changed, 15 insertions(+), 2 deletions(-)

diffs (52 lines):

diff -r faa7d6c473f7 -r 3654b56b6fd2 src/lib-imap-client/imapc-client.c
--- a/src/lib-imap-client/imapc-client.c	Thu Apr 23 19:29:43 2015 +0300
+++ b/src/lib-imap-client/imapc-client.c	Thu Apr 23 19:37:25 2015 +0300
@@ -25,6 +25,7 @@
 	{ "NAMESPACE", IMAPC_CAPABILITY_NAMESPACE },
 	{ "UNSELECT", IMAPC_CAPABILITY_UNSELECT },
 	{ "ESEARCH", IMAPC_CAPABILITY_ESEARCH },
+	{ "WITHIN", IMAPC_CAPABILITY_WITHIN },
 
 	{ "IMAP4REV1", IMAPC_CAPABILITY_IMAP4REV1 },
 	{ NULL, 0 }
diff -r faa7d6c473f7 -r 3654b56b6fd2 src/lib-imap-client/imapc-client.h
--- a/src/lib-imap-client/imapc-client.h	Thu Apr 23 19:29:43 2015 +0300
+++ b/src/lib-imap-client/imapc-client.h	Thu Apr 23 19:37:25 2015 +0300
@@ -24,6 +24,7 @@
 	IMAPC_CAPABILITY_NAMESPACE	= 0x200,
 	IMAPC_CAPABILITY_UNSELECT	= 0x400,
 	IMAPC_CAPABILITY_ESEARCH	= 0x800,
+	IMAPC_CAPABILITY_WITHIN		= 0x1000,
 
 	IMAPC_CAPABILITY_IMAP4REV1	= 0x40000000
 };
diff -r faa7d6c473f7 -r 3654b56b6fd2 src/lib-storage/index/imapc/imapc-search.c
--- a/src/lib-storage/index/imapc/imapc-search.c	Thu Apr 23 19:29:43 2015 +0300
+++ b/src/lib-storage/index/imapc/imapc-search.c	Thu Apr 23 19:37:25 2015 +0300
@@ -98,13 +98,24 @@
 			imap_write_seq_range(str, &uids);
 		} T_END;
 		return TRUE;
+	case SEARCH_BEFORE:
+	case SEARCH_SINCE:
+		if ((capa & IMAPC_CAPABILITY_WITHIN) == 0) {
+			/* a bit kludgy way to check this.. */
+			unsigned int pos = str_len(str);
+			if (!mail_search_arg_to_imap(str, arg, &error))
+				return FALSE;
+			if (strncasecmp(str_c(str) + pos, "OLDER", 5) == 0 ||
+			    strncasecmp(str_c(str) + pos, "YOUNGER", 7) == 0)
+				return FALSE;
+			return TRUE;
+		}
+		/* fall thrugh */
 	case SEARCH_ALL:
 	case SEARCH_UIDSET:
 	case SEARCH_FLAGS:
 	case SEARCH_KEYWORDS:
-	case SEARCH_BEFORE:
 	case SEARCH_ON:
-	case SEARCH_SINCE:
 	case SEARCH_SMALLER:
 	case SEARCH_LARGER:
 	case SEARCH_HEADER:


More information about the dovecot-cvs mailing list