mu: make attachment test a bit looser

Consider all 'inline' text parts attachments too, unless they're
'text/plain' or something that looks like a signature.

It's a heuristic so we might get some new corner-cases.. let's see.
This commit is contained in:
djcb
2018-12-30 18:46:43 +02:00
parent 9352219dcf
commit 53c1b0a069

View File

@ -59,7 +59,6 @@ mu_msg_file_new (const char* filepath, const char *mdir, GError **err)
return self;
}
void
mu_msg_file_destroy (MuMsgFile *self)
{
@ -72,7 +71,6 @@ mu_msg_file_destroy (MuMsgFile *self)
g_slice_free (MuMsgFile, self);
}
static gboolean
init_file_metadata (MuMsgFile *self, const char* path, const gchar* mdir,
GError **err)
@ -114,8 +112,6 @@ init_file_metadata (MuMsgFile *self, const char* path, const gchar* mdir,
return TRUE;
}
static GMimeStream*
get_mime_stream (MuMsgFile *self, const char *path, GError **err)
{
@ -224,7 +220,6 @@ get_fake_mailing_list_maybe (MuMsgFile *self)
return NULL;
}
static gchar*
get_mailing_list (MuMsgFile *self)
{
@ -253,10 +248,10 @@ get_mailing_list (MuMsgFile *self)
return res;
}
static gboolean
looks_like_attachment (GMimeObject *part)
{
GMimeContentDisposition *disp;
GMimeContentType *ctype;
const char *dispstr;
@ -268,8 +263,6 @@ looks_like_attachment (GMimeObject *part)
{ "image", "*" },
{ "audio", "*" },
{ "application", "*"},
{ "text", "x-diff" },
{ "text", "x-patch"},
{ "application", "x-patch"}
};
@ -290,6 +283,14 @@ looks_like_attachment (GMimeObject *part)
if (g_mime_content_type_is_type (ctype, "*", "pgp-signature"))
return FALSE; /* don't consider as a signature */
if (g_mime_content_type_is_type (ctype, "text", "*")) {
if (g_mime_content_type_is_type (ctype, "*", "plain") ||
g_mime_content_type_is_type (ctype, "*", "html"))
return FALSE;
else
return TRUE;
}
for (u = 0; u != G_N_ELEMENTS(att_types); ++u)
if (g_mime_content_type_is_type (
ctype, att_types[u].type, att_types[u].sub_type))
@ -298,7 +299,6 @@ looks_like_attachment (GMimeObject *part)
return FALSE;
}
static void
msg_cflags_cb (GMimeObject *parent, GMimeObject *part, MuFlags *flags)
{
@ -323,8 +323,6 @@ msg_cflags_cb (GMimeObject *parent, GMimeObject *part, MuFlags *flags)
*flags |= MU_FLAG_HAS_ATTACH;
}
static MuFlags
get_content_flags (MuMsgFile *self)
{
@ -345,11 +343,9 @@ get_content_flags (MuMsgFile *self)
g_free (ml);
}
return flags;
}
static MuFlags
get_flags (MuMsgFile *self)
{
@ -368,7 +364,6 @@ get_flags (MuMsgFile *self)
return flags;
}
static size_t
get_size (MuMsgFile *self)
{
@ -376,7 +371,6 @@ get_size (MuMsgFile *self)
return self->_size;
}
static MuMsgPrio
parse_prio_str (const char* priostr)
{
@ -426,7 +420,6 @@ get_prio (MuMsgFile *self)
return priostr ? parse_prio_str (priostr) : MU_MSG_PRIO_NORMAL;
}
/* NOTE: buffer will be *freed* or returned unchanged */
static char*
convert_to_utf8 (GMimePart *part, char *buffer)
@ -456,7 +449,6 @@ convert_to_utf8 (GMimePart *part, char *buffer)
return buffer;
}
static gchar*
stream_to_string (GMimeStream *stream, size_t buflen)
{
@ -479,7 +471,6 @@ stream_to_string (GMimeStream *stream, size_t buflen)
return buffer;
}
gchar*
mu_msg_mime_part_to_string (GMimePart *part, gboolean *err)
{
@ -528,8 +519,6 @@ cleanup:
return buffer;
}
static gboolean
contains (GSList *lst, const char *str)
{
@ -539,7 +528,6 @@ contains (GSList *lst, const char *str)
return FALSE;
}
/*
* NOTE: this will get the list of references with the oldest parent
* at the beginning */
@ -583,9 +571,6 @@ get_references (MuMsgFile *self)
return g_slist_reverse (msgids);
}
/* see: http://does-not-exist.org/mail-archives/mutt-dev/msg08249.html */
static GSList*
get_tags (MuMsgFile *self)
@ -620,8 +605,6 @@ get_tags (MuMsgFile *self)
return lst;
}
static char*
cleanup_maybe (const char *str, gboolean *do_free)
{
@ -645,8 +628,6 @@ cleanup_maybe (const char *str, gboolean *do_free)
return s;
}
G_GNUC_CONST static GMimeAddressType
address_type (MuMsgFieldId mfid)
{
@ -674,7 +655,6 @@ get_msgid (MuMsgFile *self, gboolean *do_free)
}
}
char*
mu_msg_file_get_str_field (MuMsgFile *self, MuMsgFieldId mfid,
gboolean *do_free)
@ -719,7 +699,6 @@ mu_msg_file_get_str_field (MuMsgFile *self, MuMsgFieldId mfid,
}
}
GSList*
mu_msg_file_get_str_list_field (MuMsgFile *self, MuMsgFieldId mfid)
{
@ -733,7 +712,6 @@ mu_msg_file_get_str_list_field (MuMsgFile *self, MuMsgFieldId mfid)
}
}
gint64
mu_msg_file_get_num_field (MuMsgFile *self, const MuMsgFieldId mfid)
{
@ -761,7 +739,6 @@ mu_msg_file_get_num_field (MuMsgFile *self, const MuMsgFieldId mfid)
}
}
char*
mu_msg_file_get_header (MuMsgFile *self, const char *header)
{
@ -779,7 +756,6 @@ mu_msg_file_get_header (MuMsgFile *self, const char *header)
return hdr ? mu_str_utf8ify(hdr) : NULL;
}
struct _ForeachData {
GMimeObjectForeachFunc user_func;
gpointer user_data;
@ -787,7 +763,6 @@ struct _ForeachData {
};
typedef struct _ForeachData ForeachData;
static void
foreach_cb (GMimeObject *parent, GMimeObject *part, ForeachData *fdata)
{
@ -816,7 +791,6 @@ foreach_cb (GMimeObject *parent, GMimeObject *part, ForeachData *fdata)
}
}
void
mu_mime_message_foreach (GMimeMessage *msg, gboolean decrypt,
GMimeObjectForeachFunc func, gpointer user_data)