aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-05 14:35:53 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-05 16:06:22 +0100
commit03fc6963c4947d62a541d3c989000596a1444169 (patch)
tree3bf63970801e5c29df900cdcdf246b348410c648 /src
parentd7acbc3402f81c0e97e6b1ba67fc3c031b660f0d (diff)
downloadrspamd-03fc6963c4947d62a541d3c989000596a1444169.tar.gz
rspamd-03fc6963c4947d62a541d3c989000596a1444169.zip
[Fix] Propagate colors in HTML
Diffstat (limited to 'src')
-rw-r--r--src/libserver/html.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/libserver/html.c b/src/libserver/html.c
index e20fbadce..ce388cf49 100644
--- a/src/libserver/html.c
+++ b/src/libserver/html.c
@@ -1572,9 +1572,11 @@ rspamd_html_process_block_tag (rspamd_mempool_t *pool, struct html_tag *tag,
struct html_content *hc)
{
struct html_tag_component *comp;
- struct html_block *bl;
+ struct html_block *bl, *bl_parent;
rspamd_ftok_t fstr;
GList *cur;
+ GNode *parent;
+ struct html_tag *parent_tag;
cur = tag->params->head;
bl = rspamd_mempool_alloc0 (pool, sizeof (*bl));
@@ -1616,6 +1618,37 @@ rspamd_html_process_block_tag (rspamd_mempool_t *pool, struct html_tag *tag,
cur = g_list_next (cur);
}
+ if (!bl->background_color.valid) {
+ /* Try to propagate background color from parent nodes */
+ for (parent = tag->parent; parent != NULL; parent = parent->parent) {
+ parent_tag = parent->data;
+
+ if (parent && (parent_tag->flags & FL_BLOCK) && parent_tag->extra) {
+ bl_parent = parent_tag->extra;
+
+ if (bl_parent->background_color.valid) {
+ memcpy (&bl->background_color, &bl_parent->background_color,
+ sizeof (bl->background_color));
+ }
+ }
+ }
+ }
+ if (!bl->font_color.valid) {
+ /* Try to propagate background color from parent nodes */
+ for (parent = tag->parent; parent != NULL; parent = parent->parent) {
+ parent_tag = parent->data;
+
+ if (parent && (parent_tag->flags & FL_BLOCK) && parent_tag->extra) {
+ bl_parent = parent_tag->extra;
+
+ if (bl_parent->font_color.valid) {
+ memcpy (&bl->font_color, &bl_parent->font_color,
+ sizeof (bl->font_color));
+ }
+ }
+ }
+ }
+
if (hc->blocks == NULL) {
hc->blocks = g_ptr_array_sized_new (64);
rspamd_mempool_add_destructor (pool, rspamd_ptr_array_free_hard,
@@ -1687,6 +1720,7 @@ rspamd_html_process_part_full (rspamd_mempool_t *pool, struct html_content *hc,
hc->bgcolor.d.comp.r = 255;
hc->bgcolor.d.comp.g = 255;
hc->bgcolor.d.comp.b = 255;
+ hc->bgcolor.valid = TRUE;
dest = g_byte_array_sized_new (in->len / 3 * 2);