From baa26167fbb7844292cc1fd830e91bcb68e7ea48 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 17 Jul 2015 13:13:02 +0100 Subject: [PATCH] Split emails and urls. --- src/libmime/message.c | 3 ++- src/libserver/html.c | 18 +++++++++++++----- src/libserver/html.h | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/libmime/message.c b/src/libmime/message.c index cdd532f5a..a8df8aea9 100644 --- a/src/libmime/message.c +++ b/src/libmime/message.c @@ -1142,7 +1142,8 @@ process_text_part (struct rspamd_task *task, text_part->html, part_content, &text_part->urls_offset, - task->urls); + task->urls, + task->emails); rspamd_url_text_extract (task->task_pool, task, text_part, TRUE); diff --git a/src/libserver/html.c b/src/libserver/html.c index 18a71930f..421a89829 100644 --- a/src/libserver/html.c +++ b/src/libserver/html.c @@ -1243,12 +1243,13 @@ rspamd_html_process_url_tag (rspamd_mempool_t *pool, struct html_tag *tag) GByteArray* rspamd_html_process_part_full (rspamd_mempool_t *pool, struct html_content *hc, - GByteArray *in, GList **exceptions, GHashTable *urls) + GByteArray *in, GList **exceptions, GHashTable *urls, GHashTable *emails) { const guchar *p, *c, *end, *tag_start = NULL, *savep = NULL; guchar t; gboolean closing = FALSE, need_decode = FALSE, save_space = FALSE, balanced; GByteArray *dest; + GHashTable *target_tbl; guint obrace = 0, ebrace = 0; GNode *cur_level = NULL; gint substate, len, href_offset = -1; @@ -1565,13 +1566,20 @@ rspamd_html_process_part_full (rspamd_mempool_t *pool, struct html_content *hc, if (url != NULL) { - turl = g_hash_table_lookup (urls, url); + if (url->protocol == PROTOCOL_MAILTO) { + target_tbl = emails; + } + else { + target_tbl = urls; + } + + turl = g_hash_table_lookup (target_tbl, url); if (turl != NULL && turl->phished_url == NULL) { - g_hash_table_insert (urls, url, url); + g_hash_table_insert (target_tbl, url, url); } else if (turl == NULL) { - g_hash_table_insert (urls, url, url); + g_hash_table_insert (target_tbl, url, url); } else { url = NULL; @@ -1622,5 +1630,5 @@ rspamd_html_process_part (rspamd_mempool_t *pool, struct html_content *hc, GByteArray *in) { - return rspamd_html_process_part_full (pool, hc, in, NULL, NULL); + return rspamd_html_process_part_full (pool, hc, in, NULL, NULL, NULL); } diff --git a/src/libserver/html.h b/src/libserver/html.h index 1a98a3e9a..c70d7d6ed 100644 --- a/src/libserver/html.h +++ b/src/libserver/html.h @@ -59,6 +59,6 @@ GByteArray* rspamd_html_process_part (rspamd_mempool_t *pool, GByteArray* rspamd_html_process_part_full (rspamd_mempool_t *pool, struct html_content *hc, - GByteArray *in, GList **exceptions, GHashTable *urls); + GByteArray *in, GList **exceptions, GHashTable *urls, GHashTable *emails); #endif -- 2.39.5