Skip to content

Commit

Permalink
id: quirk os=iOS os-version=7...
Browse files Browse the repository at this point in the history
Turn all searches into FUZZY searches to make BODY less crazy expensive
  • Loading branch information
Bron Gondwana authored and brong committed Mar 12, 2015
1 parent 9987ed5 commit b61e07e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions imap/imapd.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,11 @@ static int imapd_compress_done = 0; /* have we done a successful compress? */
static const char *plaintextloginalert = NULL;
static int ignorequota = 0;

#define QUIRK_SEARCHFUZZY (1<<0)
static struct id_data {
struct attvaluelist *params;
int did_id;
int quirks;
} imapd_id;

#ifdef HAVE_SSL
Expand Down Expand Up @@ -2794,6 +2796,7 @@ static void clear_id() {
static void cmd_id(char *tag)
{
int c = EOF, npair = 0;
int is_ios = 0;
static struct buf arg, field;

/* check if we've already had an ID in non-authenticated state */
Expand Down Expand Up @@ -2867,6 +2870,13 @@ static void cmd_id(char *tag)
return;
}

if (!strcmp(field.s, "os") && !strcmp(arg.s, "iOS")) {
is_ios = 1;
}
if (is_ios && !strcmp(field.s, "os-version") && arg.s[0] == '7') {
imapd_id.quirks |= QUIRK_SEARCHFUZZY;
}

/* ok, we're happy enough */
appendattvalue(&imapd_id.params, field.s, &arg);
}
Expand Down Expand Up @@ -5438,6 +5448,8 @@ static void cmd_search(char *tag, int usinguid)
searchargs = new_searchargs(tag, GETSEARCH_CHARSET_KEYWORD|GETSEARCH_RETURN,
&imapd_namespace, imapd_userid, imapd_authstate,
imapd_userisadmin || imapd_userisproxyadmin);
if (imapd_id.quirks & QUIRK_SEARCHFUZZY)
searchargs->fuzzy_depth++;
c = get_search_program(imapd_in, imapd_out, searchargs);
if (c == EOF) {
eatline(imapd_in, ' ');
Expand Down Expand Up @@ -5498,6 +5510,8 @@ static void cmd_sort(char *tag, int usinguid)
searchargs = new_searchargs(tag, GETSEARCH_CHARSET_FIRST,
&imapd_namespace, imapd_userid, imapd_authstate,
imapd_userisadmin || imapd_userisproxyadmin);
if (imapd_id.quirks & QUIRK_SEARCHFUZZY)
searchargs->fuzzy_depth++;
c = get_search_program(imapd_in, imapd_out, searchargs);
if (c == EOF) goto error;

Expand Down

0 comments on commit b61e07e

Please sign in to comment.