commit 33d2683: [Minor] Propagate images flag
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed Apr 14 09:49:04 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-04-14 10:47:15 +0100
URL: https://github.com/rspamd/rspamd/commit/33d268331ab00e377a83e3078c53042254630cf1 (HEAD -> master)
[Minor] Propagate images flag
---
src/libserver/html.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/libserver/html.c b/src/libserver/html.c
index 8dc8a8dac..5e29b3b84 100644
--- a/src/libserver/html.c
+++ b/src/libserver/html.c
@@ -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);
}
}
More information about the Commits
mailing list