aboutsummaryrefslogtreecommitdiffstats
path: root/em-format/e-mail-part-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'em-format/e-mail-part-utils.c')
-rw-r--r--em-format/e-mail-part-utils.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/em-format/e-mail-part-utils.c b/em-format/e-mail-part-utils.c
index 2e2b5f66f2..4fa7a854a0 100644
--- a/em-format/e-mail-part-utils.c
+++ b/em-format/e-mail-part-utils.c
@@ -552,3 +552,31 @@ e_mail_part_is_inline (CamelMimePart *mime_part,
/* Otherwise, use the default for this handler type. */
return (class->flags & E_MAIL_PARSER_EXTENSION_INLINE) != 0;
}
+
+/**
+ * e_mail_part_utils_body_refers:
+ * @body: text body to search for references in; can be %NULL, then returns %FALSE
+ * @cid: a Content-ID to search for; if found in body, it should be of form "cid:xxxxx"; can be %NULL
+ *
+ * Returns whether @body contains a reference to @cid enclosed in quotes;
+ * returns %FALSE if any of the arguments is %NULL.
+ **/
+gboolean
+e_mail_part_utils_body_refers (const gchar *body,
+ const gchar *cid)
+{
+ const gchar *ptr;
+
+ if (!body || !cid || !*cid)
+ return FALSE;
+
+ ptr = body;
+ while (ptr = strstr (ptr, cid), ptr != NULL) {
+ if (ptr - body > 1 && ptr[-1] == '\"' && ptr[strlen (cid)] == '\"')
+ return TRUE;
+
+ ptr++;
+ }
+
+ return FALSE;
+}