diff --git a/lib/mu-msg-sexp.c b/lib/mu-msg-sexp.c index 02bcffbc..aad62a92 100644 --- a/lib/mu-msg-sexp.c +++ b/lib/mu-msg-sexp.c @@ -353,21 +353,27 @@ get_part_type_string (MuMsgPartType ptype) static void each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo) { - char *name, *tmp, *parttype; + char *name, *encname, *tmp, *parttype; char *tmpfile, *cid; name = mu_msg_part_get_filename (part, TRUE); + encname = name ? + mu_str_escape_c_literal(name, TRUE) : + g_strdup("\"noname\""); + g_free (name); + tmpfile = get_temp_file_maybe (msg, part, pinfo->opts); parttype = get_part_type_string (part->part_type); - cid = mu_str_escape_c_literal(mu_msg_part_get_content_id(part), TRUE); + cid = mu_str_escape_c_literal(mu_msg_part_get_content_id(part), + TRUE); tmp = g_strdup_printf - ("%s(:index %d :name \"%s\" :mime-type \"%s/%s\"%s%s " + ("%s(:index %d :name %s :mime-type \"%s/%s\"%s%s " ":type %s " ":attachment %s %s%s :size %i %s %s)", pinfo->parts ? pinfo->parts: "", part->index, - name ? mu_str_escape_c_literal(name, FALSE) : "noname", + encname, part->type ? part->type : "application", part->subtype ? part->subtype : "octet-stream", tmpfile ? " :temp" : "", tmpfile ? tmpfile : "", @@ -378,7 +384,7 @@ each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo) sig_verdict (part), dec_verdict (part)); - g_free (name); + g_free (encname); g_free (tmpfile); g_free (parttype); g_free (cid); diff --git a/mu/mu-cmd-server.c b/mu/mu-cmd-server.c index ce22a193..fb07a44b 100644 --- a/mu/mu-cmd-server.c +++ b/mu/mu-cmd-server.c @@ -441,8 +441,8 @@ typedef struct _PartInfo PartInfo; static void each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo) { - char *att, *cachefile; - GError *err; + char *att, *cachefile, *encfile; + GError *err; /* exclude things that don't look like proper attachments, * unless they're images */ @@ -458,11 +458,14 @@ each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo) return; } - att = g_strdup_printf ( - "(:file-name \"%s\" :mime-type \"%s/%s\")", - cachefile, part->type, part->subtype); - pinfo->attlist = g_slist_append (pinfo->attlist, att); + encfile = mu_str_escape_c_literal(cachefile, TRUE); g_free (cachefile); + + att = g_strdup_printf ( + "(:file-name %s :mime-type \"%s/%s\")", + encfile, part->type, part->subtype); + pinfo->attlist = g_slist_append (pinfo->attlist, att); + g_free (encfile); } @@ -544,10 +547,10 @@ compose_type (const char *typestr) static MuError cmd_compose (ServerContext *ctx, GHashTable *args, GError **err) { - const gchar *typestr; - char *sexp, *atts; - unsigned ctype; - MuMsgOptions opts; + const gchar *typestr; + char *sexp, *atts; + unsigned ctype; + MuMsgOptions opts; opts = get_encrypted_msg_opts (args); @@ -570,7 +573,8 @@ cmd_compose (ServerContext *ctx, GHashTable *args, GError **err) return MU_OK; } sexp = mu_msg_to_sexp (msg, atoi(docidstr), NULL, opts); - atts = (ctype == FORWARD) ? include_attachments (msg, opts) : NULL; + atts = (ctype == FORWARD) ? + include_attachments (msg, opts) : NULL; mu_msg_unref (msg); } else atts = sexp = NULL;