diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-02-13 15:27:23 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-02-13 15:27:23 +0000 |
commit | 7bd3e7952b85327bdf5e83404aca5feedcb54ef3 (patch) | |
tree | 83a36cfc1c49d6407ad5a2859b51d54c0ea81dfa /src/lua/lua_url.c | |
parent | 5244d25f3b57d7c46ba82413aedc6116d6cb294c (diff) | |
download | rspamd-7bd3e7952b85327bdf5e83404aca5feedcb54ef3.tar.gz rspamd-7bd3e7952b85327bdf5e83404aca5feedcb54ef3.zip |
[Minor] Add method to find displayed urls
Diffstat (limited to 'src/lua/lua_url.c')
-rw-r--r-- | src/lua/lua_url.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c index 60a01b6ce..abbbef512 100644 --- a/src/lua/lua_url.c +++ b/src/lua/lua_url.c @@ -52,6 +52,7 @@ LUA_FUNCTION_DEF (url, to_table); LUA_FUNCTION_DEF (url, is_phished); LUA_FUNCTION_DEF (url, is_redirected); LUA_FUNCTION_DEF (url, is_obscured); +LUA_FUNCTION_DEF (url, is_html_displayed); LUA_FUNCTION_DEF (url, get_phished); LUA_FUNCTION_DEF (url, get_tag); LUA_FUNCTION_DEF (url, get_tags); @@ -74,6 +75,7 @@ static const struct luaL_reg urllib_m[] = { LUA_INTERFACE_DEF (url, is_phished), LUA_INTERFACE_DEF (url, is_redirected), LUA_INTERFACE_DEF (url, is_obscured), + LUA_INTERFACE_DEF (url, is_html_displayed), LUA_INTERFACE_DEF (url, get_phished), LUA_INTERFACE_DEF (url, get_tag), LUA_INTERFACE_DEF (url, get_tags), @@ -316,6 +318,27 @@ lua_url_is_obscured (lua_State *L) return 1; } + +/*** + * @method url:is_html_displayed() + * Check whether URL is just displayed in HTML (e.g. NOT a real href) + * @return {boolean} `true` if URL is displayed only + */ +static gint +lua_url_is_html_displayed (lua_State *L) +{ + struct rspamd_lua_url *url = lua_check_url (L, 1); + + if (url != NULL) { + lua_pushboolean (L, url->url->flags & RSPAMD_URL_FLAG_HTML_DISPLAYED); + } + else { + lua_pushnil (L); + } + + return 1; +} + /*** * @method url:get_tag(tag) * Returns list of string for a specific tagname for an url |