Handle IMAP search failure instead of ignoring it.
authorAndrej Kacian <ticho@claws-mail.org>
Wed, 14 Mar 2018 20:35:05 +0000 (21:35 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Thu, 15 Mar 2018 19:32:37 +0000 (20:32 +0100)
Error out on protocol error during search, disconnect
the IMAP session, and display an error dialog about it.

Closes bug 3986 - IMAP quick search using non-ASCII
characters creates an infinite loop

src/imap.c

index 5c99688..8d0ded9 100644 (file)
@@ -2468,7 +2468,12 @@ static gint      search_msgs             (Folder                 *folder,
        if (progress_cb)
                progress_cb(progress_data, TRUE, container->total_msgs, 0, container->total_msgs);
 
-       if (result == MAILIMAP_NO_ERROR) {
+       if (result == MAILIMAP_ERROR_PROTOCOL) {
+               debug_print("search_msgs - got protocol error, aborting\n");
+               imap_handle_error(SESSION(session), NULL, result);
+               alertpanel_error_log(_("Search failed due to server error."));
+               return -1;
+       } if (result == MAILIMAP_NO_ERROR) {
                gint result = 0;
 
                *msgs = imap_uid_list_from_lep(uidlist, &result);
@@ -2489,9 +2494,12 @@ static gint      search_msgs             (Folder                 *folder,
                if (IMAP_FOLDER(folder)->search_charset_supported)
                        return search_msgs(folder, container, msgs, on_server, predicate,
                                   progress_cb, progress_data);
-               else
+               else {
+                       imap_handle_error(SESSION(session), NULL, result);
                        return -1;
+               }
        } else {
+               imap_handle_error(SESSION(session), NULL, result);
                return -1;
        }
 }