]> source.dussan.org Git - rspamd.git/commitdiff
Fix processing of HTML tags.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 17 Nov 2015 16:11:31 +0000 (16:11 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 17 Nov 2015 16:12:42 +0000 (16:12 +0000)
src/libserver/html.c
src/libserver/html.h

index 248e57bf5f74a9738795d61a186b82f1f031c2f2..2d1896d8459706deda7f015db2b29be2474a650c 100644 (file)
@@ -895,12 +895,6 @@ rspamd_html_process_tag (rspamd_mempool_t *pool, struct html_content *hc,
                /* Block tag */
                nnode = g_node_new (tag);
 
-               if (tag->params) {
-                       rspamd_mempool_add_destructor (pool,
-                                       (rspamd_mempool_destruct_t) g_list_free,
-                                       tag->params);
-               }
-
                if (tag->flags & FL_CLOSING) {
                        if (!*cur_level) {
                                msg_debug_pool ("bad parent node");
@@ -961,7 +955,7 @@ rspamd_html_process_tag (rspamd_mempool_t *pool, struct html_content *hc,
        comp->type = (comp_type);                                                                       \
        comp->start = NULL;                                                                                     \
        comp->len = 0;                                                                                          \
-       tag->params = g_list_append (tag->params, comp);                        \
+       g_queue_push_tail (tag->params, comp);                                          \
        ret = TRUE;                                                                                                     \
 } while(0)
 
@@ -1217,7 +1211,8 @@ rspamd_html_parse_tag_content (rspamd_mempool_t *pool,
                if (store) {
                        if (*savep != NULL) {
                                g_assert (tag->params != NULL);
-                               comp = (g_list_first (tag->params))->data;
+                               comp = g_queue_peek_tail (tag->params);
+                               g_assert (comp != NULL);
                                comp->len = in - *savep;
                                comp->start = *savep;
                                *savep = NULL;
@@ -1233,7 +1228,8 @@ rspamd_html_parse_tag_content (rspamd_mempool_t *pool,
                if (store) {
                        if (*savep != NULL) {
                                g_assert (tag->params != NULL);
-                               comp = (g_list_first (tag->params))->data;
+                               comp = g_queue_peek_tail (tag->params);
+                               g_assert (comp != NULL);
                                comp->len = in - *savep;
                                comp->start = *savep;
                                *savep = NULL;
@@ -1252,7 +1248,8 @@ rspamd_html_parse_tag_content (rspamd_mempool_t *pool,
                if (store) {
                        if (*savep != NULL) {
                                g_assert (tag->params != NULL);
-                               comp = (g_list_first (tag->params))->data;
+                               comp = g_queue_peek_tail (tag->params);
+                               g_assert (comp != NULL);
                                comp->len = in - *savep;
                                comp->start = *savep;
                                *savep = NULL;
@@ -1289,7 +1286,7 @@ rspamd_html_process_url_tag (rspamd_mempool_t *pool, struct html_tag *tag)
        GList *cur;
        gint rc;
 
-       cur = tag->params;
+       cur = tag->params->head;
 
        while (cur) {
                comp = cur->data;
@@ -1356,7 +1353,7 @@ rspamd_html_process_img_tag (rspamd_mempool_t *pool, struct html_tag *tag,
        GList *cur;
        gulong val;
 
-       cur = tag->params;
+       cur = tag->params->head;
        img = rspamd_mempool_alloc0 (pool, sizeof (*img));
 
        while (cur) {
@@ -1563,7 +1560,7 @@ rspamd_html_process_block_tag (rspamd_mempool_t *pool, struct html_tag *tag,
        rspamd_ftok_t fstr;
        GList *cur;
 
-       cur = tag->params;
+       cur = tag->params->head;
        bl = rspamd_mempool_alloc0 (pool, sizeof (*bl));
        bl->tag = tag;
 
@@ -1708,6 +1705,9 @@ rspamd_html_process_part_full (rspamd_mempool_t *pool, struct html_content *hc,
                                substate = 0;
                                savep = NULL;
                                cur_tag = rspamd_mempool_alloc0 (pool, sizeof (*cur_tag));
+                               cur_tag->params = g_queue_new ();
+                               rspamd_mempool_add_destructor (pool,
+                                               (rspamd_mempool_destruct_t)g_queue_free, cur_tag->params);
                                break;
                        }
 
index 3410605175d75167abd5e1229031d5a9c674b353..3fe16696175c6a3c3587c04573681ba49cd75b6b 100644 (file)
@@ -79,7 +79,7 @@ struct html_block {
 struct html_tag {
        gint id;
        struct html_tag_component name;
-       GList *params;
+       GQueue *params;
        gint flags;
 };