Navigation Menu

Skip to content

Commit

Permalink
[Minor] Add link tag basic processing
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Jul 16, 2020
1 parent 8e8448a commit 4fb77a8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/libserver/html.c
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/libserver/html.h
Expand Up @@ -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 {
Expand Down

0 comments on commit 4fb77a8

Please sign in to comment.