[evolution-data-server] Bug 735200 - [IMAPx] Fails to handle QUOTA response with no quotas



commit 4730ee9325d0c605849aa2c38ea1faa776c918d2
Author: Jeffrey Hutzelman <jhutz cmu edu>
Date:   Mon Sep 1 17:55:27 2014 +0200

    Bug 735200 - [IMAPx] Fails to handle QUOTA response with no quotas
    
    The untagged QUOTA response includes a list containing quota usage and
    limits for each quota resource for which a limit applies. Per RFC 2087
    section 5.1, "The list contains zero or more triplets.".
    
    Fix the parser to handle an empty list. Additionally, when the IMAP
    server supports the quota extension but reports no quotas for a folder,
    return G_IO_ERROR_NOT_SUPPORTED rather than G_IO_ERROR_NOT_FOUND, since
    Evolution (and maybe other callers) special-cases the former error code.

 camel/providers/imapx/camel-imapx-folder.c |    2 +-
 camel/providers/imapx/camel-imapx-utils.c  |   62 +++++++++++++--------------
 2 files changed, 31 insertions(+), 33 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-folder.c b/camel/providers/imapx/camel-imapx-folder.c
index fd6c7f2..3fa6e17 100644
--- a/camel/providers/imapx/camel-imapx-folder.c
+++ b/camel/providers/imapx/camel-imapx-folder.c
@@ -792,7 +792,7 @@ imapx_get_quota_info_sync (CamelFolder *folder,
 
        if (quota_info == NULL)
                g_set_error (
-                       error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+                       error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
                        _("No quota information available for folder '%s'"),
                        camel_folder_get_full_name (folder));
 
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index f5d18f6..4590939 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -2774,7 +2774,7 @@ camel_imapx_parse_quota (CamelIMAPXInputStream *stream,
        g_return_val_if_fail (out_quota_info != NULL, FALSE);
 
        /* quota_response  ::= "QUOTA" SP astring SP quota_list
-        * quota_list      ::= "(" #quota_resource ")"
+        * quota_list      ::= "(" *quota_resource ")"
         * quota_resource  ::= atom SP number SP number */
 
        success = camel_imapx_input_stream_astring (
@@ -2799,46 +2799,44 @@ camel_imapx_parse_quota (CamelIMAPXInputStream *stream,
                        goto fail;
        }
 
-quota_resource:
+       while (TRUE) {
+               /* Peek at the next token, and break
+                * out of the loop if we get a close-paren. */
+               tok = camel_imapx_input_stream_token (
+                       stream, &token, &len, cancellable, error);
+               if (tok == ')')
+                       break;
+               if (tok == IMAPX_TOK_ERROR)
+                       goto fail;
+               camel_imapx_input_stream_ungettoken (
+                       stream, tok, token, len);
 
-       success = camel_imapx_input_stream_atom (
-               stream, &token, &len, cancellable, error);
+               success = camel_imapx_input_stream_atom (
+                       stream, &token, &len, cancellable, error);
 
-       if (!success)
-               goto fail;
+               if (!success)
+                       goto fail;
 
-       resource_name = g_strdup ((gchar *) token);
+               resource_name = g_strdup ((gchar *) token);
 
-       success = camel_imapx_input_stream_number (
-               stream, &resource_usage, cancellable, error);
+               success = camel_imapx_input_stream_number (
+                       stream, &resource_usage, cancellable, error);
 
-       if (!success)
-               goto fail;
+               if (!success)
+                       goto fail;
 
-       success = camel_imapx_input_stream_number (
-               stream, &resource_limit, cancellable, error);
+               success = camel_imapx_input_stream_number (
+                       stream, &resource_limit, cancellable, error);
 
-       if (!success)
-               goto fail;
-
-       info = camel_folder_quota_info_new (
-               resource_name, resource_usage, resource_limit);
-       g_queue_push_tail (&queue, info);
+               if (!success)
+                       goto fail;
 
-       g_free (resource_name);
-       resource_name = NULL;
+               info = camel_folder_quota_info_new (
+                       resource_name, resource_usage, resource_limit);
+               g_queue_push_tail (&queue, info);
 
-       tok = camel_imapx_input_stream_token (
-               stream, &token, &len, cancellable, error);
-       switch (tok) {
-               case IMAPX_TOK_ERROR:
-                       goto fail;
-               case ')':
-                       break;
-               default:
-                       camel_imapx_input_stream_ungettoken (
-                               stream, tok, token, len);
-                       goto quota_resource;
+               g_free (resource_name);
+               resource_name = NULL;
        }
 
        /* Eat the newline. */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]