]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Propagate content length of invisible tags
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 23 Jun 2018 12:49:22 +0000 (13:49 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 23 Jun 2018 12:49:22 +0000 (13:49 +0100)
src/libserver/html.c
src/libserver/html.h

index 85602aec5fd785c1ceee6ef72d082db11804cdca..68a2c984361750b66ee434ea9642310f11607cba 100644 (file)
@@ -2647,6 +2647,13 @@ rspamd_html_process_part_full (rspamd_mempool_t *pool, struct html_content *hc,
                                p ++;
                        }
                        else {
+                               if (content_tag) {
+                                       if (content_tag->content == NULL) {
+                                               content_tag->content = c;
+                                       }
+
+                                       content_tag->content_length += p - c;
+                               }
                                state = tag_begin;
                        }
                        break;
@@ -2929,6 +2936,13 @@ rspamd_html_process_part_full (rspamd_mempool_t *pool, struct html_content *hc,
                }
        }
 
+       if (hc->html_tags) {
+               g_node_traverse (hc->html_tags, G_POST_ORDER, G_TRAVERSE_ALL, -1,
+                               rspamd_html_propagate_lengths, NULL);
+       }
+
+       g_queue_free (styles_blocks);
+
        return dest;
 }
 
index 44a14a0f7d449f0b9edaa941916af5f96f258d5d..abe38606ecbef1beecd150c111b954e9dbd1afe3 100644 (file)
@@ -95,9 +95,9 @@ struct html_block {
 struct html_tag {
        gint id;
        gint flags;
-       gsize content_length;
-       const gchar *content;
+       guint content_length;
        struct html_tag_component name;
+       const gchar *content;
        GQueue *params;
        gpointer extra; /** Additional data associated with tag (e.g. image) */
        GNode *parent;