aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_url.c
diff options
context:
space:
mode:
authorMiecio Za <miecio@miecio.net>2019-02-27 11:56:35 +0100
committerMiecio Za <miecio@miecio.net>2019-02-27 11:56:35 +0100
commitadd9595913c3f456c6328a53801739cdca70da9d (patch)
tree8c4e1af1f5c98014b14787ff036c3dc591206f72 /src/lua/lua_url.c
parent54493e55a5691de3ba8eaa998aae3824402191db (diff)
downloadrspamd-add9595913c3f456c6328a53801739cdca70da9d.tar.gz
rspamd-add9595913c3f456c6328a53801739cdca70da9d.zip
[Feature] Export visible part of url to lua
Export visible part of url to lua
Diffstat (limited to 'src/lua/lua_url.c')
-rw-r--r--src/lua/lua_url.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c
index 0a301e96d..7bad50359 100644
--- a/src/lua/lua_url.c
+++ b/src/lua/lua_url.c
@@ -63,6 +63,7 @@ LUA_FUNCTION_DEF (url, get_tag);
LUA_FUNCTION_DEF (url, get_count);
LUA_FUNCTION_DEF (url, get_tags);
LUA_FUNCTION_DEF (url, add_tag);
+LUA_FUNCTION_DEF (url, get_visible);
LUA_FUNCTION_DEF (url, create);
LUA_FUNCTION_DEF (url, init);
LUA_FUNCTION_DEF (url, all);
@@ -89,6 +90,7 @@ static const struct luaL_reg urllib_m[] = {
LUA_INTERFACE_DEF (url, get_tag),
LUA_INTERFACE_DEF (url, get_tags),
LUA_INTERFACE_DEF (url, add_tag),
+ LUA_INTERFACE_DEF (url, get_visible),
LUA_INTERFACE_DEF (url, get_count),
LUA_INTERFACE_DEF (url, get_flags),
{"get_redirected", lua_url_get_phished},
@@ -650,6 +652,27 @@ lua_url_get_count (lua_State *L)
return 1;
}
+ /***
+* @method url:get_visible()
+* Get visible part of the url with html tags stripped
+* @return {string} url string
+*/
+static gint
+lua_url_get_visible (lua_State *L)
+{
+ LUA_TRACE_POINT;
+ struct rspamd_lua_url *url = lua_check_url (L, 1);
+
+ if (url != NULL) {
+ lua_pushlstring (L, url->url->visible_part, url->url->visible_partlen);
+ }
+ else {
+ lua_pushnil (L);
+ }
+
+return 1;
+}
+
/***
* @method url:to_table()
* Return url as a table with the following fields: