static void
process_image (struct rspamd_task *task, struct rspamd_mime_part *part)
{
- struct rspamd_mime_header *rh;
- struct rspamd_mime_text_part *tp;
- struct html_image *himg;
- const gchar *cid, *html_cid;
- guint cid_len, i, j;
struct rspamd_image *img;
-
img = rspamd_maybe_process_image (task->task_pool, &part->parsed_data);
if (img != NULL) {
part->flags |= RSPAMD_MIME_PART_IMAGE;
part->specific.img = img;
+ }
+}
+
+const gchar *
+rspamd_image_type_str (enum rspamd_image_type type)
+{
+ switch (type) {
+ case IMAGE_TYPE_PNG:
+ return "PNG";
+ break;
+ case IMAGE_TYPE_JPG:
+ return "JPEG";
+ break;
+ case IMAGE_TYPE_GIF:
+ return "GIF";
+ break;
+ case IMAGE_TYPE_BMP:
+ return "BMP";
+ break;
+ default:
+ break;
+ }
+ return "unknown";
+}
+
+static void
+rspamd_image_process_part (struct rspamd_task *task, struct rspamd_mime_part *part)
+{
+ struct rspamd_mime_header *rh;
+ struct rspamd_mime_text_part *tp;
+ struct html_image *himg;
+ const gchar *cid, *html_cid;
+ guint cid_len, i, j;
+ struct rspamd_image *img;
+
+ img = (struct rspamd_image *)part->specific.img;
+
+ if (img) {
/* Check Content-Id */
rh = rspamd_message_get_header_from_hash (part->raw_headers,
"Content-Id");
cid_len --;
}
-
PTR_ARRAY_FOREACH (MESSAGE_FIELD (task, text_parts), i, tp) {
if (IS_PART_HTML (tp) && tp->html != NULL &&
- tp->html->images != NULL) {
+ tp->html->images != NULL) {
for (j = 0; j < tp->html->images->len; j ++) {
himg = g_ptr_array_index (tp->html->images, j);
if ((himg->flags & RSPAMD_HTML_FLAG_IMAGE_EMBEDDED) &&
- himg->src) {
+ himg->src) {
html_cid = himg->src;
if (strncmp (html_cid, "cid:", 4) == 0) {
}
if (strlen (html_cid) == cid_len &&
- memcmp (html_cid, cid, cid_len) == 0) {
+ memcmp (html_cid, cid, cid_len) == 0) {
img->html_image = himg;
himg->embedded_image = img;
if (himg->height == 0) {
himg->height = img->height;
}
+
if (himg->width == 0) {
himg->width = img->width;
}
}
}
}
-
}
-
}
}
}
-const gchar *
-rspamd_image_type_str (enum rspamd_image_type type)
+void
+rspamd_images_link (struct rspamd_task *task)
{
- switch (type) {
- case IMAGE_TYPE_PNG:
- return "PNG";
- break;
- case IMAGE_TYPE_JPG:
- return "JPEG";
- break;
- case IMAGE_TYPE_GIF:
- return "GIF";
- break;
- case IMAGE_TYPE_BMP:
- return "BMP";
- break;
- default:
- break;
- }
+ struct rspamd_mime_part *part;
+ guint i;
- return "unknown";
-}
+ PTR_ARRAY_FOREACH (MESSAGE_FIELD (task, parts), i, part) {
+ if (part->flags & RSPAMD_MIME_PART_IMAGE) {
+ rspamd_image_process_part (task, part);
+ }
+ }
+}
\ No newline at end of file