|
|
@@ -31,6 +31,11 @@ struct html_tag_def { |
|
|
|
guint flags; |
|
|
|
}; |
|
|
|
|
|
|
|
#define msg_debug_html(...) rspamd_default_log_function (G_LOG_LEVEL_DEBUG, \ |
|
|
|
"html", pool->tag.uid, \ |
|
|
|
G_STRFUNC, \ |
|
|
|
__VA_ARGS__) |
|
|
|
|
|
|
|
static struct html_tag_def tag_defs[] = { |
|
|
|
/* W3C defined elements */ |
|
|
|
{Tag_A, "a", (0)}, |
|
|
@@ -818,7 +823,7 @@ rspamd_html_process_tag (rspamd_mempool_t *pool, struct html_content *hc, |
|
|
|
|
|
|
|
if (tag->flags & FL_CLOSING) { |
|
|
|
if (!*cur_level) { |
|
|
|
msg_debug_pool ("bad parent node"); |
|
|
|
msg_debug_html ("bad parent node"); |
|
|
|
g_node_destroy (nnode); |
|
|
|
return FALSE; |
|
|
|
} |
|
|
@@ -826,7 +831,7 @@ rspamd_html_process_tag (rspamd_mempool_t *pool, struct html_content *hc, |
|
|
|
g_node_append (*cur_level, nnode); |
|
|
|
|
|
|
|
if (!rspamd_html_check_balance (nnode, cur_level)) { |
|
|
|
msg_debug_pool ( |
|
|
|
msg_debug_html ( |
|
|
|
"mark part as unbalanced as it has not pairable closing tags"); |
|
|
|
hc->flags |= RSPAMD_HTML_FLAG_UNBALANCED; |
|
|
|
*balanced = FALSE; |
|
|
@@ -1346,7 +1351,7 @@ rspamd_process_html_url (rspamd_mempool_t *pool, struct rspamd_url *url, |
|
|
|
|
|
|
|
if (rc == URI_ERRNO_OK && |
|
|
|
url->hostlen > 0) { |
|
|
|
msg_debug_pool ("found url %s in query of url" |
|
|
|
msg_debug_html ("found url %s in query of url" |
|
|
|
" %*s", url_str, url->querylen, url->query); |
|
|
|
|
|
|
|
if (!g_hash_table_lookup (target, |
|
|
@@ -1543,7 +1548,7 @@ rspamd_html_process_style (rspamd_mempool_t *pool, struct html_block *bl, |
|
|
|
|| (klen == 10 && g_ascii_strncasecmp (key, "font-color", 10) == 0)) { |
|
|
|
|
|
|
|
rspamd_html_process_color (c, p - c, &bl->font_color); |
|
|
|
msg_debug_pool ("got color: %xd", bl->font_color.d.val); |
|
|
|
msg_debug_html ("got color: %xd", bl->font_color.d.val); |
|
|
|
} |
|
|
|
else if ((klen == 16 && g_ascii_strncasecmp (key, |
|
|
|
"background-color", 16) == 0) || |
|
|
@@ -1551,7 +1556,7 @@ rspamd_html_process_style (rspamd_mempool_t *pool, struct html_block *bl, |
|
|
|
"background", 10) == 0)) { |
|
|
|
|
|
|
|
rspamd_html_process_color (c, p - c, &bl->background_color); |
|
|
|
msg_debug_pool ("got bgcolor: %xd", bl->background_color.d.val); |
|
|
|
msg_debug_html ("got bgcolor: %xd", bl->background_color.d.val); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -1600,13 +1605,13 @@ rspamd_html_process_block_tag (rspamd_mempool_t *pool, struct html_tag *tag, |
|
|
|
fstr.begin = (gchar *)comp->start; |
|
|
|
fstr.len = comp->len; |
|
|
|
rspamd_html_process_color (comp->start, comp->len, &bl->font_color); |
|
|
|
msg_debug_pool ("got color: %xd", bl->font_color.d.val); |
|
|
|
msg_debug_html ("got color: %xd", bl->font_color.d.val); |
|
|
|
} |
|
|
|
else if (comp->type == RSPAMD_HTML_COMPONENT_BGCOLOR && comp->len > 0) { |
|
|
|
fstr.begin = (gchar *)comp->start; |
|
|
|
fstr.len = comp->len; |
|
|
|
rspamd_html_process_color (comp->start, comp->len, &bl->background_color); |
|
|
|
msg_debug_pool ("got color: %xd", bl->font_color.d.val); |
|
|
|
msg_debug_html ("got color: %xd", bl->font_color.d.val); |
|
|
|
|
|
|
|
if (tag->id == Tag_BODY) { |
|
|
|
/* Set global background color */ |
|
|
@@ -1616,14 +1621,14 @@ rspamd_html_process_block_tag (rspamd_mempool_t *pool, struct html_tag *tag, |
|
|
|
else if (comp->type == RSPAMD_HTML_COMPONENT_STYLE && comp->len > 0) { |
|
|
|
bl->style.len = comp->len; |
|
|
|
bl->style.start = comp->start; |
|
|
|
msg_debug_pool ("got style: %*s", (gint)bl->style.len, bl->style.start); |
|
|
|
msg_debug_html ("got style: %*s", (gint)bl->style.len, bl->style.start); |
|
|
|
rspamd_html_process_style (pool, bl, hc, comp->start, comp->len); |
|
|
|
} |
|
|
|
else if (comp->type == RSPAMD_HTML_COMPONENT_CLASS && comp->len > 0) { |
|
|
|
fstr.begin = (gchar *)comp->start; |
|
|
|
fstr.len = comp->len; |
|
|
|
bl->class = rspamd_mempool_ftokdup (pool, &fstr); |
|
|
|
msg_debug_pool ("got class: %s", bl->class); |
|
|
|
msg_debug_html ("got class: %s", bl->class); |
|
|
|
} |
|
|
|
|
|
|
|
cur = g_list_next (cur); |