From: Vsevolod Stakhov Date: Wed, 23 Jun 2021 12:14:26 +0000 (+0100) Subject: [Minor] Fix styles processing X-Git-Tag: 3.0~251 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5e8161b784138491c141dcea042af8d263413c00;p=rspamd.git [Minor] Fix styles processing --- diff --git a/src/libserver/css/css_selector.cxx b/src/libserver/css/css_selector.cxx index 28b64a9fd..75baec8f2 100644 --- a/src/libserver/css/css_selector.cxx +++ b/src/libserver/css/css_selector.cxx @@ -152,6 +152,9 @@ auto process_selector_tokens(rspamd_mempool_t *pool, msg_debug_css("attached selector: %s", cur_selector->debug_str().c_str()); ret.push_back(std::move(cur_selector)); } + else { + msg_debug_css("not attached selector, state: %d", static_cast(state)); + } can_continue = false; } diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index 6a7a6facf..9261258bc 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -1473,14 +1473,17 @@ html_process_input(rspamd_mempool_t *pool, case content_style: { /* - * We just search for the first substring and then pass * the content to the parser (if needed) + * + * TODO: Handle other stuff, we actually need an FSM here to find + * the ending tag... */ - auto end_style = rspamd_substring_search (p, end - p, - "", 8); + if (end_style == -1) { /* Invalid style */ - state = tag_content; + state = html_text_content; } else { @@ -1540,16 +1543,11 @@ html_process_input(rspamd_mempool_t *pool, content_parser_env.reset(); if (cur_tag != nullptr) { - state = html_text_content; cur_tag->content_offset = p - start + 1; - if (!html_process_tag(pool, hc, cur_tag, tags_stack, - c - start, p - start)) { - if (cur_tag->id == Tag_STYLE) { - state = content_style; - } - } + html_process_tag(pool, hc, cur_tag, tags_stack, + c - start, p - start); if (cur_tag->id != -1 && cur_tag->id < N_TAGS) { if (cur_tag->flags & CM_UNIQUE) { @@ -1623,7 +1621,13 @@ html_process_input(rspamd_mempool_t *pool, } } - state = html_text_content; + if (cur_tag->id == Tag_STYLE && !(cur_tag->flags & FL_CLOSING)) { + state = content_style; + } + else { + state = html_text_content; + } + p++; c = p; cur_tag = NULL;