From: Vsevolod Stakhov Date: Sun, 11 Jul 2021 09:38:23 +0000 (+0100) Subject: [Project] Html: Support 'hidden' attribute X-Git-Tag: 3.0~184 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=839b70825f6f3705d713bad322de90231c2e3035;p=rspamd.git [Project] Html: Support 'hidden' attribute --- diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index 0f5aefcde..28f26ec65 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -66,6 +66,7 @@ auto html_components_map = frozen::make_unordered_map void { std::optional maybe_fgcolor, maybe_bgcolor; + bool hidden = false; for (const auto ¶m : tag->components) { if (param.type == html_component_type::RSPAMD_HTML_COMPONENT_COLOR) { @@ -921,12 +923,20 @@ html_process_block_tag(rspamd_mempool_t *pool, struct html_tag *tag, if (param.type == html_component_type::RSPAMD_HTML_COMPONENT_STYLE) { tag->block = rspamd::css::parse_css_declaration(pool, param.value); } + + if (param.type == html_component_type::RSPAMD_HTML_COMPONENT_HIDDEN) { + hidden = true; + } } if (!tag->block) { tag->block = html_block::undefined_html_block_pool(pool); } + if (hidden) { + tag->block->set_display(false); + } + if (maybe_fgcolor) { tag->block->set_fgcolor(maybe_fgcolor->to_color().value()); } @@ -2080,6 +2090,7 @@ TEST_CASE("html text extraction") "

\n" " 

", " Sincerely,\n Skype Web\n"}, + {"lala", "lala\n"}, /* bgcolor propagation */ {"\n" "FRevie" diff --git a/src/libserver/html/html_tag.hxx b/src/libserver/html/html_tag.hxx index a221a48ff..fab1b3867 100644 --- a/src/libserver/html/html_tag.hxx +++ b/src/libserver/html/html_tag.hxx @@ -41,6 +41,7 @@ enum class html_component_type : std::uint8_t { RSPAMD_HTML_COMPONENT_REL, RSPAMD_HTML_COMPONENT_ALT, RSPAMD_HTML_COMPONENT_ID, + RSPAMD_HTML_COMPONENT_HIDDEN, }; /* Public tags flags */