commit 4fb77a8: [Minor] Add link tag basic processing
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Jul 16 15:21:10 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-07-16 16:08:41 +0100
URL: https://github.com/rspamd/rspamd/commit/4fb77a80c94a7600c45d06a05d1410de7e50de65
[Minor] Add link tag basic processing
---
src/libserver/html.c | 32 ++++++++++++++++++++++++++++++++
src/libserver/html.h | 1 +
2 files changed, 33 insertions(+)
diff --git a/src/libserver/html.c b/src/libserver/html.c
index 7b570bdc4..0ba2a374a 100644
--- a/src/libserver/html.c
+++ b/src/libserver/html.c
@@ -923,6 +923,9 @@ rspamd_html_parse_tag_component (rspamd_mempool_t *pool,
if (g_ascii_strncasecmp (p, "src", len) == 0) {
NEW_COMPONENT (RSPAMD_HTML_COMPONENT_HREF);
}
+ else if (g_ascii_strncasecmp (p, "rel", len) == 0) {
+ NEW_COMPONENT (RSPAMD_HTML_COMPONENT_REL);
+ }
}
else if (len == 4) {
if (g_ascii_strncasecmp (p, "href", len) == 0) {
@@ -1893,6 +1896,31 @@ rspamd_html_process_img_tag (rspamd_mempool_t *pool, struct html_tag *tag,
tag->extra = img;
}
+static void
+rspamd_html_process_link_tag (rspamd_mempool_t *pool, struct html_tag *tag,
+ struct html_content *hc, khash_t (rspamd_url_hash) *url_set,
+ GPtrArray *part_urls)
+{
+ struct html_tag_component *comp;
+ GList *cur;
+
+ cur = tag->params->head;
+
+ while (cur) {
+ comp = cur->data;
+
+ if (comp->type == RSPAMD_HTML_COMPONENT_REL && comp->len > 0) {
+ if (comp->len == sizeof ("icon") - 1 &&
+ rspamd_lc_cmp (comp->start, "icon", sizeof ("icon") - 1) == 0) {
+
+ rspamd_html_process_img_tag (pool, tag, hc, url_set, part_urls);
+ }
+ }
+
+ cur = g_list_next (cur);
+ }
+}
+
static void
rspamd_html_process_color (const gchar *line, guint len, struct html_color *cl)
{
@@ -3163,6 +3191,10 @@ rspamd_html_process_part_full (rspamd_mempool_t *pool,
rspamd_html_process_img_tag (pool, cur_tag, hc, url_set,
part_urls);
}
+ else if (cur_tag->id == Tag_LINK && !(cur_tag->flags & FL_CLOSING)) {
+ rspamd_html_process_link_tag (pool, cur_tag, hc, url_set,
+ part_urls);
+ }
else if (cur_tag->flags & FL_BLOCK) {
struct html_block *bl;
diff --git a/src/libserver/html.h b/src/libserver/html.h
index b319964ce..377eda430 100644
--- a/src/libserver/html.h
+++ b/src/libserver/html.h
@@ -42,6 +42,7 @@ enum html_component_type {
RSPAMD_HTML_COMPONENT_WIDTH,
RSPAMD_HTML_COMPONENT_HEIGHT,
RSPAMD_HTML_COMPONENT_SIZE,
+ RSPAMD_HTML_COMPONENT_REL,
};
struct html_tag_component {
More information about the Commits
mailing list