From: Vsevolod Stakhov Date: Sat, 23 Jun 2018 12:49:22 +0000 (+0100) Subject: [Feature] Propagate content length of invisible tags X-Git-Tag: 1.7.7~50 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=eac6f15d9ea61cafdf706fc7faec45d23aacdd1d;p=rspamd.git [Feature] Propagate content length of invisible tags --- diff --git a/src/libserver/html.c b/src/libserver/html.c index 85602aec5..68a2c9843 100644 --- a/src/libserver/html.c +++ b/src/libserver/html.c @@ -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; } diff --git a/src/libserver/html.h b/src/libserver/html.h index 44a14a0f7..abe38606e 100644 --- a/src/libserver/html.h +++ b/src/libserver/html.h @@ -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;