Skip to content

Commit

Permalink
jmap_calendar: return unsupportedFilter for too large SQL queries
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Stepanek <[email protected]>
  • Loading branch information
rsto committed Jun 27, 2023
1 parent 56892df commit 5825a74
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions imap/jmap_calendar.c
Original file line number Diff line number Diff line change
Expand Up @@ -7119,7 +7119,7 @@ static int eventquery_run(jmap_req_t *req,
{
time_t before = caldav_eternity;
time_t after = caldav_epoch;
int r = HTTP_NOT_IMPLEMENTED;
int r = 0, r_db = 0;
enum caldav_sort *sort = NULL;
struct buf buf = BUF_INITIALIZER;
size_t nsort = 0;
Expand Down Expand Up @@ -7176,7 +7176,7 @@ static int eventquery_run(jmap_req_t *req,
struct eventquery_fastpath_rock rock = {
req, query, is_sharee, BUF_INITIALIZER
};
r = caldav_foreach_jscal(db, req->userid, jscal_filter, NULL,
r_db = caldav_foreach_jscal(db, req->userid, jscal_filter, NULL,
sort, nsort, eventquery_fastpath_cb, &rock);
buf_free(&rock.buf);
is_fastpath = 1;
Expand All @@ -7197,11 +7197,12 @@ static int eventquery_run(jmap_req_t *req,
};

enum caldav_sort mboxsort = CAL_SORT_MAILBOX;
r = caldav_foreach_jscal(db, req->userid, jscal_filter, NULL,
r_db = caldav_foreach_jscal(db, req->userid, jscal_filter, NULL,
args.expandrecur ? &mboxsort : sort,
args.expandrecur ? 1 : nsort,
eventquery_cb, &rock);
jmap_closembox(req, &rock.mailbox);
if (r_db) goto done;
}

if (args.expandrecur) {
Expand Down Expand Up @@ -7311,6 +7312,12 @@ static int eventquery_run(jmap_req_t *req,
eventquery_match_free(&match);
}
}
if (r_db == SQLDB_ERR_LIMIT && !*err) {
*err = json_pack("{s:s}", "type", "unsupportedFilter");
}
else if (r_db) {
r = HTTP_SERVER_ERROR;
}
ptrarray_fini(&matches);
caldav_jscal_filter_fini(jscal_filter);
free(jscal_filter);
Expand Down

0 comments on commit 5825a74

Please sign in to comment.