summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-09-07 16:34:49 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-09-07 16:34:49 +0100
commitaf46edb50eeba9d035a0c4d0bf32a800955c5ae9 (patch)
treef065ac5c08cc35dc1590f5c9e47dcf9f117fad72 /src
parentd2ca78731396d34148d3b2ab1d0503d07621557b (diff)
downloadrspamd-af46edb50eeba9d035a0c4d0bf32a800955c5ae9.tar.gz
rspamd-af46edb50eeba9d035a0c4d0bf32a800955c5ae9.zip
[Minor] Allow to get invisible content from html
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_html.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/lua/lua_html.cxx b/src/lua/lua_html.cxx
index 8767d1a11..b47a110d4 100644
--- a/src/lua/lua_html.cxx
+++ b/src/lua/lua_html.cxx
@@ -104,11 +104,19 @@ LUA_FUNCTION_DEF (html, get_images);
*/
LUA_FUNCTION_DEF (html, foreach_tag);
+/***
+ * @method html:get_invisible()
+ * Returns invisible content of the HTML data
+ * @return
+ */
+LUA_FUNCTION_DEF (html, get_invisible);
+
static const struct luaL_reg htmllib_m[] = {
LUA_INTERFACE_DEF (html, has_tag),
LUA_INTERFACE_DEF (html, has_property),
LUA_INTERFACE_DEF (html, get_images),
LUA_INTERFACE_DEF (html, foreach_tag),
+ LUA_INTERFACE_DEF (html, get_invisible),
{"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -485,6 +493,22 @@ lua_html_foreach_tag (lua_State *L)
}
static gint
+lua_html_get_invisible (lua_State *L)
+{
+ LUA_TRACE_POINT;
+ auto *hc = lua_check_html (L, 1);
+
+ if (hc != NULL) {
+ lua_new_text (L, hc->invisible.c_str(), hc->invisible.size(), false);
+ }
+ else {
+ lua_newtable (L);
+ }
+
+ return 1;
+}
+
+static gint
lua_html_tag_get_type (lua_State *L)
{
LUA_TRACE_POINT;