diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-06-11 15:08:53 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-06-11 15:09:10 +0100 |
commit | 0e68af8a70b3deffcbeb42fc8ccf1fa38bc9da38 (patch) | |
tree | b255b30e6a06c834b3e891cb4948fb2db38eb0bc | |
parent | 9a73d7f1d24983570f28e8fda0066d63ea2644d1 (diff) | |
download | rspamd-0e68af8a70b3deffcbeb42fc8ccf1fa38bc9da38.tar.gz rspamd-0e68af8a70b3deffcbeb42fc8ccf1fa38bc9da38.zip |
[Project] Html/Css: Fix some issues found
-rw-r--r-- | src/libserver/css/css_tokeniser.cxx | 2 | ||||
-rw-r--r-- | src/libserver/html/html.cxx | 22 | ||||
-rw-r--r-- | src/libserver/html/html_tag.hxx | 15 |
3 files changed, 29 insertions, 10 deletions
diff --git a/src/libserver/css/css_tokeniser.cxx b/src/libserver/css/css_tokeniser.cxx index f31fdc009..22544053c 100644 --- a/src/libserver/css/css_tokeniser.cxx +++ b/src/libserver/css/css_tokeniser.cxx @@ -360,7 +360,7 @@ auto css_tokeniser::consume_number() -> struct css_parser_token } if (i > offset) { - double num; + float num; /* I wish it was supported properly */ //auto conv_res = std::from_chars(&input[offset], &input[i], num); diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index 1d13c2466..23dabc4d5 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -225,6 +225,18 @@ html_process_tag(rspamd_mempool_t *pool, return true; } +auto +html_component_from_string(const std::string_view &st) -> std::optional<html_component_type> +{ + auto known_component_it = html_components_map.find(st); + + if (known_component_it != html_components_map.end()) { + return known_component_it->second; + } + else { + return std::nullopt; + } +} static auto find_tag_component_name(rspamd_mempool_t *pool, @@ -1048,7 +1060,6 @@ html_process_input(rspamd_mempool_t *pool, struct rspamd_url *url = NULL; gint len, href_offset = -1; struct html_tag *cur_tag = NULL, *content_tag = NULL; - std::vector<html_block *> blocks_stack; std::vector<html_tag *> tags_stack; struct tag_content_parser_state content_parser_env; @@ -1614,15 +1625,8 @@ html_process_input(rspamd_mempool_t *pool, } if (cur_tag->flags & FL_BLOCK) { - struct html_block *bl; - if (cur_tag->flags & FL_CLOSING) { - /* Just remove block element from the queue if any */ - if (!blocks_stack.empty()) { - blocks_stack.pop_back(); - } - } - else { + if (!(cur_tag->flags & FL_CLOSING)) { html_process_block_tag(pool, cur_tag, hc); } } diff --git a/src/libserver/html/html_tag.hxx b/src/libserver/html/html_tag.hxx index 251ba148c..906dc15d4 100644 --- a/src/libserver/html/html_tag.hxx +++ b/src/libserver/html/html_tag.hxx @@ -39,6 +39,12 @@ enum class html_component_type : std::uint8_t { RSPAMD_HTML_COMPONENT_REL, RSPAMD_HTML_COMPONENT_ALT, }; +/** + * Returns component type from a string + * @param st + * @return + */ +auto html_component_from_string(const std::string_view &st) -> std::optional<html_component_type>; using html_tag_extra_t = std::variant<std::monostate, struct rspamd_url *, struct html_image *>; struct html_tag_component { @@ -73,6 +79,15 @@ struct html_tag { return std::nullopt; } + + auto find_component(std::optional<html_component_type> what) const -> std::optional<std::string_view> + { + if (what) { + return find_component(what.value()); + } + + return std::nullopt; + } }; } |