diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-04-30 16:55:22 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-04-30 16:55:22 +0100 |
commit | 91d051fea0bbed8f005493bdf0bd99b680ee7393 (patch) | |
tree | aea2b2abdebecc5a373bce6e404cf03bc9136de8 /src/libserver | |
parent | ce94689221ea0575d4ea4f249201be2ee4531eee (diff) | |
download | rspamd-91d051fea0bbed8f005493bdf0bd99b680ee7393.tar.gz rspamd-91d051fea0bbed8f005493bdf0bd99b680ee7393.zip |
Revert "[Minor] Do not append unbalanced closing tags"
This reverts commit e1339c646f9a910f4cc1805020af35a7c1f82a1d.
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/html.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/libserver/html.c b/src/libserver/html.c index 33f3dc676..80fa3479b 100644 --- a/src/libserver/html.c +++ b/src/libserver/html.c @@ -268,26 +268,25 @@ rspamd_html_library_init (void) } static gboolean -rspamd_html_check_balance (struct html_tag *arg, GNode ** cur_level) +rspamd_html_check_balance (GNode * node, GNode ** cur_level) { - struct html_tag *tmp; + struct html_tag *arg = node->data, *tmp; GNode *cur; if (arg->flags & FL_CLOSING) { /* First of all check whether this tag is closing tag for parent node */ - cur = *cur_level; - + cur = node->parent; while (cur && cur->data) { tmp = cur->data; - if (tmp->id == arg->id && (tmp->flags & FL_CLOSED) == 0) { tmp->flags |= FL_CLOSED; + /* Destroy current node as we find corresponding parent node */ + g_node_destroy (node); /* Change level */ *cur_level = cur->parent; return TRUE; } - cur = cur->parent; } } @@ -811,17 +810,19 @@ rspamd_html_process_tag (rspamd_mempool_t *pool, struct html_content *hc, } if (hc->total_tags < max_tags) { - if (!rspamd_html_check_balance (tag, cur_level)) { - if (!(hc->flags & RSPAMD_HTML_FLAG_UNBALANCED)) { - msg_debug_html ( - "mark part as unbalanced as it has not pairable closing tags"); - hc->flags |= RSPAMD_HTML_FLAG_UNBALANCED; - *balanced = FALSE; - } + nnode = g_node_new (tag); + g_node_append (*cur_level, nnode); + + if (!rspamd_html_check_balance (nnode, cur_level)) { + msg_debug_html ( + "mark part as unbalanced as it has not pairable closing tags"); + hc->flags |= RSPAMD_HTML_FLAG_UNBALANCED; + *balanced = FALSE; } else { - hc->total_tags ++; *balanced = TRUE; } + + hc->total_tags ++; } } else { |