diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-04-15 17:22:18 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-04-15 17:22:18 +0100 |
commit | 4fd256c6140dfa68ffef719cb4c3913a94f24403 (patch) | |
tree | 639affcc6d29e3e63aa4f49ee3e43f934f479469 | |
parent | b2d60bca95218992b832738984ef009f7639bb09 (diff) | |
download | rspamd-4fd256c6140dfa68ffef719cb4c3913a94f24403.tar.gz rspamd-4fd256c6140dfa68ffef719cb4c3913a94f24403.zip |
Use detected TLD in surbl module.
-rw-r--r-- | src/plugins/surbl.c | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index ceb70f4d2..8c375749b 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -582,7 +582,7 @@ format_surbl_request (rspamd_mempool_t * pool, gchar *result = NULL, *dots[MAX_LEVELS], num_buf[sizeof("18446744073709551616")], *p; gint len, slen, r, i, dots_num = 0, level = MAX_LEVELS; - gboolean is_numeric = TRUE; + gboolean is_numeric = TRUE, found_exception = FALSE; guint64 ip_num; rspamd_fstring_t f; @@ -675,38 +675,47 @@ format_surbl_request (rspamd_mempool_t * pool, (dots[dots_num - i - 1] - hostname->begin + 1); if (g_hash_table_lookup (t, &f) != NULL) { level = dots_num - i - 1; + found_exception = TRUE; break; } } } } - if (level != MAX_LEVELS) { - if (level == 0) { - r = rspamd_snprintf (result, - len, - "%*s", - (gint)hostname->len, - hostname->begin); + + if (found_exception || url->tldlen == 0) { + if (level != MAX_LEVELS) { + if (level == 0) { + r = rspamd_snprintf (result, + len, + "%V", + hostname); + } + else { + r = rspamd_snprintf (result, len, "%*s", + (gint)(hostname->len - + (dots[level - 1] - hostname->begin + 1)), + dots[level - 1] + 1); + } } - else { + else if (dots_num >= 2) { r = rspamd_snprintf (result, len, "%*s", (gint)(hostname->len - - (dots[level - 1] - hostname->begin + 1)), - dots[level - 1] + 1); + (dots[dots_num - 2] - hostname->begin + 1)), + dots[dots_num - 2] + 1); + } + else { + r = rspamd_snprintf (result, + len, + "%V", + hostname); } - } - else if (dots_num >= 2) { - r = rspamd_snprintf (result, len, "%*s", - (gint)(hostname->len - - (dots[dots_num - 2] - hostname->begin + 1)), - dots[dots_num - 2] + 1); } else { r = rspamd_snprintf (result, - len, - "%*s", - (gint)hostname->len, - hostname->begin); + len, + "%*s", + url->tldlen, + url->tld); } } |