mu: properly escape include file-names (forward)

We weren't properly escaping filenames when returning them for
forwarding. Let's do so now.
This commit is contained in:
djcb
2017-04-09 11:31:39 +03:00
parent 98b998b86d
commit 855a8a5c5e
2 changed files with 26 additions and 16 deletions

View File

@ -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;