mirror of https://github.com/djcb/mu.git
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:
parent
98b998b86d
commit
855a8a5c5e
|
@ -353,21 +353,27 @@ get_part_type_string (MuMsgPartType ptype)
|
||||||
static void
|
static void
|
||||||
each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo)
|
each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo)
|
||||||
{
|
{
|
||||||
char *name, *tmp, *parttype;
|
char *name, *encname, *tmp, *parttype;
|
||||||
char *tmpfile, *cid;
|
char *tmpfile, *cid;
|
||||||
|
|
||||||
name = mu_msg_part_get_filename (part, TRUE);
|
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);
|
tmpfile = get_temp_file_maybe (msg, part, pinfo->opts);
|
||||||
parttype = get_part_type_string (part->part_type);
|
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
|
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 "
|
":type %s "
|
||||||
":attachment %s %s%s :size %i %s %s)",
|
":attachment %s %s%s :size %i %s %s)",
|
||||||
pinfo->parts ? pinfo->parts: "",
|
pinfo->parts ? pinfo->parts: "",
|
||||||
part->index,
|
part->index,
|
||||||
name ? mu_str_escape_c_literal(name, FALSE) : "noname",
|
encname,
|
||||||
part->type ? part->type : "application",
|
part->type ? part->type : "application",
|
||||||
part->subtype ? part->subtype : "octet-stream",
|
part->subtype ? part->subtype : "octet-stream",
|
||||||
tmpfile ? " :temp" : "", tmpfile ? tmpfile : "",
|
tmpfile ? " :temp" : "", tmpfile ? tmpfile : "",
|
||||||
|
@ -378,7 +384,7 @@ each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo)
|
||||||
sig_verdict (part),
|
sig_verdict (part),
|
||||||
dec_verdict (part));
|
dec_verdict (part));
|
||||||
|
|
||||||
g_free (name);
|
g_free (encname);
|
||||||
g_free (tmpfile);
|
g_free (tmpfile);
|
||||||
g_free (parttype);
|
g_free (parttype);
|
||||||
g_free (cid);
|
g_free (cid);
|
||||||
|
|
|
@ -441,8 +441,8 @@ typedef struct _PartInfo PartInfo;
|
||||||
static void
|
static void
|
||||||
each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo)
|
each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo)
|
||||||
{
|
{
|
||||||
char *att, *cachefile;
|
char *att, *cachefile, *encfile;
|
||||||
GError *err;
|
GError *err;
|
||||||
|
|
||||||
/* exclude things that don't look like proper attachments,
|
/* exclude things that don't look like proper attachments,
|
||||||
* unless they're images */
|
* unless they're images */
|
||||||
|
@ -458,11 +458,14 @@ each_part (MuMsg *msg, MuMsgPart *part, PartInfo *pinfo)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
att = g_strdup_printf (
|
encfile = mu_str_escape_c_literal(cachefile, TRUE);
|
||||||
"(:file-name \"%s\" :mime-type \"%s/%s\")",
|
|
||||||
cachefile, part->type, part->subtype);
|
|
||||||
pinfo->attlist = g_slist_append (pinfo->attlist, att);
|
|
||||||
g_free (cachefile);
|
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
|
static MuError
|
||||||
cmd_compose (ServerContext *ctx, GHashTable *args, GError **err)
|
cmd_compose (ServerContext *ctx, GHashTable *args, GError **err)
|
||||||
{
|
{
|
||||||
const gchar *typestr;
|
const gchar *typestr;
|
||||||
char *sexp, *atts;
|
char *sexp, *atts;
|
||||||
unsigned ctype;
|
unsigned ctype;
|
||||||
MuMsgOptions opts;
|
MuMsgOptions opts;
|
||||||
|
|
||||||
opts = get_encrypted_msg_opts (args);
|
opts = get_encrypted_msg_opts (args);
|
||||||
|
|
||||||
|
@ -570,7 +573,8 @@ cmd_compose (ServerContext *ctx, GHashTable *args, GError **err)
|
||||||
return MU_OK;
|
return MU_OK;
|
||||||
}
|
}
|
||||||
sexp = mu_msg_to_sexp (msg, atoi(docidstr), NULL, opts);
|
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);
|
mu_msg_unref (msg);
|
||||||
} else
|
} else
|
||||||
atts = sexp = NULL;
|
atts = sexp = NULL;
|
||||||
|
|
Loading…
Reference in New Issue