]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: If FETCH BINARY fails because of invalid MIME part data, return [UNKNOWN-CTE...
authorTimo Sirainen <tss@iki.fi>
Fri, 2 May 2014 08:06:27 +0000 (11:06 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 2 May 2014 08:06:27 +0000 (11:06 +0300)
src/imap/cmd-fetch.c
src/imap/imap-fetch-body.c

index c5e1c588190bb07da7c93b98023470ae727e000f..f48d639634070591e93b1fb1cc59f90a0e2d9c94 100644 (file)
@@ -198,8 +198,10 @@ static bool cmd_fetch_finish(struct imap_fetch_context *ctx,
                }
 
                errstr = mailbox_get_last_error(cmd->client->mailbox, &error);
-               if (error == MAIL_ERROR_CONVERSION) {
-                       /* BINARY found unsupported Content-Transfer-Encoding */
+               if (error == MAIL_ERROR_CONVERSION ||
+                   error == MAIL_ERROR_INVALIDDATA) {
+                       /* a) BINARY found unsupported Content-Transfer-Encoding
+                          b) Content was invalid */
                        tagged_reply = t_strdup_printf(
                                "NO ["IMAP_RESP_CODE_UNKNOWN_CTE"] %s", errstr);
                } else {
index 6439ee6f91a6ad5500d589d2023196679e7e701e..4676aa59707ede066c258b6cd972cbf0a8584748 100644 (file)
@@ -163,16 +163,8 @@ static int fetch_body_msgpart(struct imap_fetch_context *ctx, struct mail *mail,
                return 1;
        }
 
-       if (imap_msgpart_open(mail, body->msgpart, &result) < 0) {
-               if (!body->binary ||
-                   mailbox_get_last_mail_error(mail->box) != MAIL_ERROR_INVALIDDATA)
-                       return -1;
-               /* tried to do BINARY fetch for a MIME part with broken
-                  content */
-               str = get_prefix(&ctx->state, body, (uoff_t)-1, FALSE);
-               o_stream_nsend(ctx->client->output, str_data(str), str_len(str));
-               return 1;
-       }
+       if (imap_msgpart_open(mail, body->msgpart, &result) < 0)
+               return -1;
        ctx->state.cur_input = result.input;
        ctx->state.cur_size = result.size;
        ctx->state.cur_size_field = result.size_field;
@@ -197,13 +189,8 @@ static int fetch_binary_size(struct imap_fetch_context *ctx, struct mail *mail,
                return 1;
        }
 
-       if (imap_msgpart_size(mail, body->msgpart, &size) < 0) {
-               if (mailbox_get_last_mail_error(mail->box) != MAIL_ERROR_INVALIDDATA)
-                       return -1;
-               /* tried to do BINARY.SIZE fetch for a MIME part with broken
-                  content */
-               size = 0;
-       }
+       if (imap_msgpart_size(mail, body->msgpart, &size) < 0)
+               return -1;
 
        str = t_str_new(128);
        if (ctx->state.cur_first)