From: Vsevolod Stakhov Date: Tue, 6 Jul 2021 15:36:46 +0000 (+0100) Subject: [Project] Html: Fix parent propagation X-Git-Tag: 3.0~204 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fb4eb10d3e9a0d908d7606cb8aab0cf10db35299;p=thirdparty%2Frspamd.git [Project] Html: Fix parent propagation --- diff --git a/src/libserver/css/css_property.cxx b/src/libserver/css/css_property.cxx index 1dd73026dc..992d5a0b01 100644 --- a/src/libserver/css/css_property.cxx +++ b/src/libserver/css/css_property.cxx @@ -27,6 +27,7 @@ constexpr const auto prop_names_map = frozen::make_unordered_map(css_property_type::PROPERTY_NYI)); +static_assert(prop_names_map.size() >= static_cast(css_property_type::PROPERTY_NYI)); auto token_string_to_property(const std::string_view &inp) -> css_property_type diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index 86265b74e2..a026326e86 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -1030,7 +1030,7 @@ html_append_content(struct html_content *hc, std::string_view data, bool transpa /* Replace all visible characters with spaces */ auto start = std::next(hc->parsed.begin(), cur_offset); std::replace_if(start, std::end(hc->parsed), [](const auto c) { - return g_ascii_isprint(c); + return !g_ascii_isspace(c); }, ' '); } @@ -2073,6 +2073,11 @@ TEST_CASE("html text extraction") "

\n" " 

", " Sincerely,\n Skype Web\n"}, + /* bgcolor propagation */ + {"\n" + "FRevie\n" + "wF̹", + " Review"}, }; rspamd_url_init(NULL); diff --git a/src/libserver/html/html_block.hxx b/src/libserver/html/html_block.hxx index 28ab3bae12..122d35aa32 100644 --- a/src/libserver/html/html_block.hxx +++ b/src/libserver/html/html_block.hxx @@ -115,11 +115,16 @@ struct html_block { auto simple_prop = [&](auto mask_val, auto &our_val, auto other_val) constexpr -> void { if (!(mask & mask_val) && (other.mask & mask_val)) { our_val = other_val; + mask |= mask_val; } }; simple_prop(fg_color_mask, fg_color, other.fg_color); simple_prop(bg_color_mask, bg_color, other.bg_color); - simple_prop(display_mask, display, other.display); + + if (other.has_display() && !other.is_visible()) { + simple_prop(display_mask, display, other.display); + mask |= other.mask&(transparent_flag|invisible_flag); + } /* Sizes are very different * We can have multiple cases: