[evolution-data-server] I#16 - [IMAPx] BODYSTRUCTURE extension fields not skipped properly



commit 15b39b753ece5ad294b2ae718cc2bb5d63367491
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jul 9 15:54:10 2018 +0200

    I#16 - [IMAPx] BODYSTRUCTURE extension fields not skipped properly
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/issues/16

 src/camel/providers/imapx/camel-imapx-utils.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/camel/providers/imapx/camel-imapx-utils.c b/src/camel/providers/imapx/camel-imapx-utils.c
index dd6878522..074bca045 100644
--- a/src/camel/providers/imapx/camel-imapx-utils.c
+++ b/src/camel/providers/imapx/camel-imapx-utils.c
@@ -1306,7 +1306,7 @@ imapx_parse_body (CamelIMAPXInputStream *stream,
                   GCancellable *cancellable,
                   GError **error)
 {
-       gint tok;
+       gint tok, nested_extension = 0;
        guint len;
        guchar *token;
        struct _CamelMessageContentInfo * cinfo = NULL;
@@ -1516,14 +1516,20 @@ imapx_parse_body (CamelIMAPXInputStream *stream,
        }
 
        /* soak up any other extension fields that may be present */
-       /* there should only be simple tokens, no lists */
        do {
                tok = camel_imapx_input_stream_token (
                        stream, &token, &len, cancellable, &local_error);
 
                if (local_error)
                        goto error;
-       } while (tok != ')' && tok != IMAPX_TOK_ERROR);
+
+               if (tok == '(') {
+                       nested_extension++;
+               } else if (tok == ')' && nested_extension > 0) {
+                       tok = 0; /* To not be used as the stop condition */
+                       nested_extension--;
+               }
+       } while ((nested_extension > 0 || tok != ')') && tok != IMAPX_TOK_ERROR);
 
  error:
        /* CHEN TODO handle exceptions better */


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