aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-07-23 17:09:26 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-07-23 17:09:26 +0100
commitda58251a803c482fcf23ea4b24c4c9c834ac7695 (patch)
treebd8017c4593fa4ec194231c897a27ad5d2de6513
parent09b84d4eabd808c638b48de06d0305480947fb2e (diff)
downloadrspamd-da58251a803c482fcf23ea4b24c4c9c834ac7695.tar.gz
rspamd-da58251a803c482fcf23ea4b24c4c9c834ac7695.zip
If there is no url within <a> then do not add exception.
-rw-r--r--src/libserver/html.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/libserver/html.c b/src/libserver/html.c
index 4cffb227b..ab4a0c3bb 100644
--- a/src/libserver/html.c
+++ b/src/libserver/html.c
@@ -838,7 +838,8 @@ static void
rspamd_html_url_is_phished (rspamd_mempool_t *pool,
struct rspamd_url *href_url,
const guchar *url_text,
- gsize len)
+ gsize len,
+ gboolean *url_found)
{
struct rspamd_url *text_url;
gint rc, state = 0;
@@ -859,6 +860,8 @@ rspamd_html_url_is_phished (rspamd_mempool_t *pool,
href_url->phished_url = text_url;
}
}
+
+ *url_found = TRUE;
}
else {
msg_info ("extract of url '%s' failed: %s",
@@ -1360,7 +1363,8 @@ rspamd_html_process_part_full (rspamd_mempool_t *pool, struct html_content *hc,
{
const guchar *p, *c, *end, *tag_start = NULL, *savep = NULL;
guchar t;
- gboolean closing = FALSE, need_decode = FALSE, save_space = FALSE, balanced;
+ gboolean closing = FALSE, need_decode = FALSE, save_space = FALSE,
+ balanced, url_text;
GByteArray *dest;
GHashTable *target_tbl;
guint obrace = 0, ebrace = 0;
@@ -1717,22 +1721,22 @@ rspamd_html_process_part_full (rspamd_mempool_t *pool, struct html_content *hc,
}
else if (cur_tag->flags & FL_CLOSING) {
/* Insert exception */
- if (exceptions && href_offset != -1
- && (gint)dest->len > href_offset) {
- ex = rspamd_mempool_alloc (pool, sizeof (*ex));
- ex->pos = href_offset;
- ex->len = dest->len - href_offset;
-
- *exceptions = g_list_prepend (*exceptions, ex);
- }
-
if (url != NULL && (gint)dest->len > href_offset) {
rspamd_html_url_is_phished (pool, url,
dest->data + href_offset,
- dest->len - href_offset);
+ dest->len - href_offset,
+ &url_text);
+ if (exceptions && url_text) {
+ ex = rspamd_mempool_alloc (pool, sizeof (*ex));
+ ex->pos = href_offset;
+ ex->len = dest->len - href_offset;
+
+ *exceptions = g_list_prepend (*exceptions, ex);
+ }
}
href_offset = -1;
+ url_text = FALSE;
url = NULL;
}
}