From: Vsevolod Stakhov Date: Mon, 16 Dec 2019 11:42:35 +0000 (+0000) Subject: [Fix] Fix base tag processing according to stupid HTML renderer behaviour X-Git-Tag: 2.3~213 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fa330c601d43ea40b84edcb22465f1740d72babc;p=rspamd.git [Fix] Fix base tag processing according to stupid HTML renderer behaviour --- diff --git a/src/libserver/html.c b/src/libserver/html.c index de6e104b4..5bb3ca05b 100644 --- a/src/libserver/html.c +++ b/src/libserver/html.c @@ -60,7 +60,7 @@ static struct html_tag_def tag_defs[] = { TAG_DEF(Tag_APPLET, "applet", (CM_OBJECT | CM_IMG | CM_INLINE | CM_PARAM)), TAG_DEF(Tag_AREA, "area", (CM_BLOCK | CM_EMPTY | FL_HREF)), TAG_DEF(Tag_B, "b", (CM_INLINE|FL_BLOCK)), - TAG_DEF(Tag_BASE, "base", (CM_HEAD | CM_EMPTY | FL_HREF)), + TAG_DEF(Tag_BASE, "base", (CM_HEAD | CM_EMPTY)), TAG_DEF(Tag_BASEFONT, "basefont", (CM_INLINE | CM_EMPTY)), TAG_DEF(Tag_BDO, "bdo", (CM_INLINE)), TAG_DEF(Tag_BIG, "big", (CM_INLINE)), @@ -3031,28 +3031,20 @@ rspamd_html_process_part_full (rspamd_mempool_t *pool, struct html_content *hc, } } else if (cur_tag->id == Tag_BASE && !(cur_tag->flags & (FL_CLOSING))) { - struct html_tag *prev_tag = NULL; - - if (cur_level && cur_level->parent) { - prev_tag = cur_level->parent->data; - } - /* - * Base is allowed only within head tag but we slightly - * relax that + * Base is allowed only within head tag but HTML is retarded */ - if (!prev_tag || prev_tag->id == Tag_HEAD || - prev_tag->id == Tag_HTML) { + if (hc->base_url == NULL) { url = rspamd_html_process_url_tag (pool, cur_tag, hc); if (url != NULL) { - if (hc->base_url == NULL) { - /* We have a base tag available */ - hc->base_url = url; - } - + msg_debug_html ("got valid base tag"); + hc->base_url = url; cur_tag->extra = url; } + else { + msg_debug_html ("got invalid base tag!"); + } } }