}
if (displayed_url) {
- if (url->protocol == PROTOCOL_MAILTO) {
+ if (displayed_url->protocol == PROTOCOL_MAILTO) {
target_tbl = emails;
}
else {
}
if (target_tbl != NULL) {
- turl = g_hash_table_lookup (target_tbl, url);
+ turl = g_hash_table_lookup (target_tbl,
+ displayed_url);
if (turl != NULL) {
/* Here, we assume the following:
turl->flags &= ~RSPAMD_URL_FLAG_FROM_TEXT;
}
}
+ else {
+ g_hash_table_insert (target_tbl,
+ displayed_url, displayed_url);
+ }
}
}
}
rspamd_mempool_add_destructor (new_task->task_pool,
(rspamd_mempool_destruct_t) g_hash_table_unref,
new_task->raw_headers);
- new_task->emails = g_hash_table_new (rspamd_url_hash, rspamd_emails_cmp);
+ new_task->emails = g_hash_table_new (rspamd_email_hash, rspamd_emails_cmp);
rspamd_mempool_add_destructor (new_task->task_pool,
(rspamd_mempool_destruct_t) g_hash_table_unref,
new_task->emails);
rspamd_cryptobox_fast_hash_update (&st, url->string, url->urllen);
}
- rspamd_cryptobox_fast_hash_update (&st, &url->flags, sizeof (url->flags));
+ return rspamd_cryptobox_fast_hash_final (&st);
+}
+
+guint
+rspamd_email_hash (gconstpointer u)
+{
+ const struct rspamd_url *url = u;
+ rspamd_cryptobox_fast_hash_state_t st;
+
+ rspamd_cryptobox_fast_hash_init (&st, rspamd_hash_seed ());
+
+ if (url->hostlen > 0) {
+ rspamd_cryptobox_fast_hash_update (&st, url->host, url->hostlen);
+ }
+
+ if (url->userlen > 0) {
+ rspamd_cryptobox_fast_hash_update (&st, url->user, url->userlen);
+ }
return rspamd_cryptobox_fast_hash_final (&st);
}
rspamd_urls_cmp (gconstpointer a, gconstpointer b)
{
const struct rspamd_url *u1 = a, *u2 = b;
- int r;
+ int r = 0;
if (u1->urllen != u2->urllen) {
return FALSE;
}
else {
r = memcmp (u1->string, u2->string, u1->urllen);
- if (r == 0 && u1->flags != u2->flags) {
- /* Always insert phished urls to the tree */
- return FALSE;
- }
}
return r == 0;
rspamd_mempool_t *pool);
guint rspamd_url_hash (gconstpointer u);
+guint rspamd_email_hash (gconstpointer u);
/* Compare two emails for building emails hash */
gboolean rspamd_emails_cmp (gconstpointer a, gconstpointer b);