HUGE PATCH. This moves all of mime_parser.c and all
[citadel.git] / citadel / modules / imap / imap_search.c
index b22e74280c8cba2a6227c8e591b37891297d9324..7efc71ed6cd5db87d4f9aaddfd79fcfc9cbf687b 100644 (file)
@@ -30,6 +30,7 @@
 #include <ctype.h>
 #include <string.h>
 #include <limits.h>
+#include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
 #include "sysdep_decls.h"
@@ -41,7 +42,6 @@
 #include "policy.h"
 #include "database.h"
 #include "msgbase.h"
-#include "tools.h"
 #include "internet_addressing.h"
 #include "serv_imap.h"
 #include "imap_tools.h"
@@ -538,6 +538,19 @@ void imap_do_search(int num_items, char **itemlist, int is_uid) {
        int is_in_list = 0;
        int num_results = 0;
 
+       /* Strip parentheses.  We realize that this method will not work
+        * in all cases, but it seems to work with all currently available
+        * client software.  Revisit later...
+        */
+       for (i=0; i<num_items; ++i) {
+               if (itemlist[i][0] == '(') {
+                       strcpy(&itemlist[i][0], &itemlist[i][1]);
+               }
+               if (itemlist[i][strlen(itemlist[i])-1] == ')') {
+                       itemlist[i][strlen(itemlist[i])-1] = 0;
+               }
+       }
+
        /* If there is a BODY search criterion in the query, use our full
         * text index to disqualify messages that don't have any chance of
         * matching.  (Only do this if the index is enabled!!)