]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Propagate images flag
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 14 Apr 2021 09:47:15 +0000 (10:47 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 14 Apr 2021 09:47:15 +0000 (10:47 +0100)
src/libserver/html.c

index 8dc8a8dac1980244e2ef9614bd50f714f134b6ee..5e29b3b84545760b65b596ec9fb156de3a6b640d 100644 (file)
@@ -1765,7 +1765,8 @@ rspamd_html_url_query_callback (struct rspamd_url *url, gsize start_offset,
 
        url->flags |= RSPAMD_URL_FLAG_QUERY;
 
-       if (rspamd_url_set_add_or_increase(cbd->url_set, url, false) && cbd->part_urls) {
+       if (rspamd_url_set_add_or_increase (cbd->url_set, url, false)
+               && cbd->part_urls) {
                g_ptr_array_add (cbd->part_urls, url);
        }
 
@@ -1902,10 +1903,22 @@ rspamd_html_process_img_tag (rspamd_mempool_t *pool, struct html_tag *tag,
                                                                img->src, fstr.len, NULL);
 
                                                if (img->url) {
+                                                       struct rspamd_url *existing;
+
                                                        img->url->flags |= RSPAMD_URL_FLAG_IMAGE;
+                                                       existing = rspamd_url_set_add_or_return (url_set, img->url);
 
-                                                       if (rspamd_url_set_add_or_increase(url_set, img->url, false) &&
-                                                               part_urls) {
+                                                       if (existing != img->url) {
+                                                               /*
+                                                                * We have some other URL that could be
+                                                                * found, e.g. from another part. However,
+                                                                * we still want to set an image flag on it
+                                                                */
+                                                               existing->flags |= img->url->flags;
+                                                               existing->count ++;
+                                                       }
+                                                       else if (part_urls) {
+                                                               /* New url */
                                                                g_ptr_array_add (part_urls, img->url);
                                                        }
                                                }