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