]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Send FETCH BINARY output using literal8.
authorTimo Sirainen <tss@iki.fi>
Sat, 11 Aug 2012 02:47:03 +0000 (05:47 +0300)
committerTimo Sirainen <tss@iki.fi>
Sat, 11 Aug 2012 02:47:03 +0000 (05:47 +0300)
src/imap/imap-fetch-body.c
src/lib-imap-storage/imap-msgpart.c

index 9c670c506ce3e049c6a04a3b88f21a735a0d90d1..cd9be2a6d8375ae3a48568e7949cc0bca2ffb80e 100644 (file)
@@ -58,7 +58,7 @@ static const char *get_body_name(const struct imap_fetch_body_data *body)
 
 static string_t *get_prefix(struct imap_fetch_context *ctx,
                            const struct imap_fetch_body_data *body,
-                           uoff_t size)
+                           uoff_t size, bool has_nuls)
 {
        string_t *str;
 
@@ -70,10 +70,12 @@ static string_t *get_prefix(struct imap_fetch_context *ctx,
 
        str_append(str, get_body_name(body));
 
-       if (size != (uoff_t)-1)
-               str_printfa(str, " {%"PRIuUOFF_T"}\r\n", size);
-       else
+       if (size == (uoff_t)-1)
                str_append(str, " NIL");
+       else if (has_nuls && body->binary)
+               str_printfa(str, " ~{%"PRIuUOFF_T"}\r\n", size);
+       else
+               str_printfa(str, " {%"PRIuUOFF_T"}\r\n", size);
        return str;
 }
 
@@ -131,7 +133,8 @@ static int fetch_body_msgpart(struct imap_fetch_context *ctx, struct mail *mail,
        ctx->cur_size_field = result.size_field;
        ctx->cur_name = p_strconcat(ctx->pool, "[", body->section, "]", NULL);
 
-       str = get_prefix(ctx, body, ctx->cur_size);
+       str = get_prefix(ctx, body, ctx->cur_size,
+                        result.binary_decoded_input_has_nuls);
        o_stream_nsend(ctx->client->output, str_data(str), str_len(str));
 
        ctx->cont_handler = fetch_stream_continue;
index fa86312b572aa6dfb1d97af22e8afd6182909dff..c4c244e6534346f4597f477484fd021cdc618313 100644 (file)
@@ -665,6 +665,9 @@ int imap_msgpart_open(struct mail *mail, struct imap_msgpart *msgpart,
                use_partial_cache = TRUE;
        }
 
+       if (binary && msgpart->decode_cte_to_binary)
+               result_r->binary_decoded_input_has_nuls = TRUE;
+
        imap_msgpart_get_partial(mail, msgpart, !binary, use_partial_cache,
                                 &part_size, result_r);
        return 0;