commit 9a2991d: [Minor] Propagate images size to html linked images

Vsevolod Stakhov vsevolod at highsecure.ru
Wed May 1 12:49:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-05-01 13:20:00 +0100
URL: https://github.com/rspamd/rspamd/commit/9a2991d15c71c1a2f487f9d95d4b7a46b7832950

[Minor] Propagate images size to html linked images

---
 src/libmime/images.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/libmime/images.c b/src/libmime/images.c
index b9a54b1a0..787417ab3 100644
--- a/src/libmime/images.c
+++ b/src/libmime/images.c
@@ -19,6 +19,13 @@
 #include "message.h"
 #include "html.h"
 
+#define msg_debug_images(...)  rspamd_conditional_debug_fast (NULL, NULL, \
+        rspamd_images_log_id, "images", task->task_pool->tag.uid, \
+        G_STRFUNC, \
+        __VA_ARGS__)
+
+INIT_LOG_MODULE(images)
+
 #ifdef USABLE_GD
 #include "gd.h"
 #include "hash.h"
@@ -603,7 +610,7 @@ process_image (struct rspamd_task *task, struct rspamd_mime_part *part)
 	img = rspamd_maybe_process_image (task->task_pool, &part->parsed_data);
 
 	if (img != NULL) {
-		debug_task ("detected %s image of size %ud x %ud in message <%s>",
+		msg_debug_images ("detected %s image of size %ud x %ud in message <%s>",
 			rspamd_image_type_str (img->type),
 			img->width, img->height,
 			task->message_id);
@@ -657,8 +664,15 @@ process_image (struct rspamd_task *task, struct rspamd_mime_part *part)
 									img->html_image = himg;
 									himg->embedded_image = img;
 
-									debug_task ("found linked image by cid: <%s>",
+									msg_debug_images ("found linked image by cid: <%s>",
 											cid);
+
+									if (himg->height == 0) {
+										himg->height = img->height;
+									}
+									if (himg->width == 0) {
+										himg->width = img->width;
+									}
 								}
 							}
 						}


More information about the Commits mailing list