diff options
-rw-r--r-- | src/libserver/html/html.cxx | 2 | ||||
-rw-r--r-- | src/libserver/html/html.hxx | 14 | ||||
-rw-r--r-- | src/lua/lua_html.cxx | 2 |
3 files changed, 15 insertions, 3 deletions
diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index 1cbc1f105..e727639aa 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -1643,7 +1643,7 @@ html_process_input(rspamd_mempool_t *pool, } } - hc->traverse_tags([](const html_tag *tag) -> bool { + hc->traverse_block_tags([](const html_tag *tag) -> bool { /* Summarize content length from children */ for (const auto *cld_tag : tag->children) { tag->content_length += cld_tag->content_length; diff --git a/src/libserver/html/html.hxx b/src/libserver/html/html.hxx index c75d84ea4..3fd778ade 100644 --- a/src/libserver/html/html.hxx +++ b/src/libserver/html/html.hxx @@ -63,7 +63,7 @@ struct html_content { PRE_ORDER, POST_ORDER }; - auto traverse_tags(fu2::function<bool(const html_tag *)> &&func, + auto traverse_block_tags(fu2::function<bool(const html_tag *)> &&func, traverse_type how = traverse_type::PRE_ORDER) const -> bool { if (root_tag == nullptr) { @@ -103,6 +103,18 @@ struct html_content { } } + auto traverse_all_tags(fu2::function<bool(const html_tag *)> &&func) const -> bool { + for (const auto &tag : all_tags) { + if (!(tag->flags & (FL_CLOSING|FL_XML))) { + if (!func(tag.get())) { + return false; + } + } + } + + return true; + } + private: ~html_content() = default; }; diff --git a/src/lua/lua_html.cxx b/src/lua/lua_html.cxx index 058ef401f..7e17f835f 100644 --- a/src/lua/lua_html.cxx +++ b/src/lua/lua_html.cxx @@ -431,7 +431,7 @@ lua_html_foreach_tag (lua_State *L) } if (hc && (any || !tags.empty()) && lua_isfunction (L, 3)) { - hc->traverse_tags([&](const rspamd::html::html_tag *tag) -> bool { + hc->traverse_all_tags([&](const rspamd::html::html_tag *tag) -> bool { if (tag && (any || tags.contains(tag->id))) { lua_pushvalue(L, 3); |