commit 839b708: [Project] Html: Support 'hidden' attribute
Vsevolod Stakhov
vsevolod at highsecure.ru
Sun Jul 11 09:42:04 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-07-11 10:38:23 +0100
URL: https://github.com/rspamd/rspamd/commit/839b70825f6f3705d713bad322de90231c2e3035
[Project] Html: Support 'hidden' attribute
---
src/libserver/html/html.cxx | 11 +++++++++++
src/libserver/html/html_tag.hxx | 1 +
2 files changed, 12 insertions(+)
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<frozen::string, html_compo
{"rel", html_component_type::RSPAMD_HTML_COMPONENT_REL},
{"alt", html_component_type::RSPAMD_HTML_COMPONENT_ALT},
{"id", html_component_type::RSPAMD_HTML_COMPONENT_ID},
+ {"hidden", html_component_type::RSPAMD_HTML_COMPONENT_HIDDEN},
});
#define msg_debug_html(...) rspamd_conditional_debug_fast (NULL, NULL, \
@@ -908,6 +909,7 @@ html_process_block_tag(rspamd_mempool_t *pool, struct html_tag *tag,
struct html_content *hc) -> void
{
std::optional<css::css_value> 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")
"<p style=\"font-size: 11px; line-height: 1.2; color: #555555; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; mso-line-height-alt: 14px; margin: 0;\">\n"
" </p>",
" Sincerely,\n Skype Web\n"},
+ {"lala<p hidden>fafa</p>", "lala\n"},
/* bgcolor propagation */
{"<a style=\"display: inline-block; color: #ffffff; background-color: #00aff0;\">\n"
"<span style=\"color: #00aff0;\">F</span>Rev<span style=\"opacity: 1;\"></span></span>ie<span style=\"opacity: 1;\"></span>"
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 */
More information about the Commits
mailing list