From: Vsevolod Stakhov Date: Thu, 8 Jul 2021 15:10:10 +0000 (+0100) Subject: [Minor] Fix hex colors parsing X-Git-Tag: 3.0~191 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=83855b16bb7fb9c699cd7f4d935e58217bb41ab0;p=thirdparty%2Frspamd.git [Minor] Fix hex colors parsing --- diff --git a/src/libserver/css/css_value.cxx b/src/libserver/css/css_value.cxx index 799d5f8efc..704905cd48 100644 --- a/src/libserver/css/css_value.cxx +++ b/src/libserver/css/css_value.cxx @@ -40,10 +40,16 @@ namespace rspamd::css { auto css_value::maybe_color_from_string(const std::string_view &input) -> std::optional { - auto found_it = css_colors_map.find(input); - if (found_it != css_colors_map.end()) { - return css_value{found_it->second}; + if (input.size() > 1 && input.front() == '#') { + return css_value::maybe_color_from_hex(input.substr(1)); + } + else { + auto found_it = css_colors_map.find(input); + + if (found_it != css_colors_map.end()) { + return css_value{found_it->second}; + } } return std::nullopt; diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index b3080bd88f..346f876440 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -2132,6 +2132,9 @@ TEST_CASE("html text extraction") "FRevie" "wF̹", " Review"}, + {"\n" + "hello world\n" + "", "hello world"}, /* Colors */ {"goodbye cruel" "world", "goodbye cruelworld"},