From: Vsevolod Stakhov Date: Mon, 13 Feb 2017 15:27:23 +0000 (+0000) Subject: [Minor] Add method to find displayed urls X-Git-Tag: 1.5.0~112 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7bd3e7952b85327bdf5e83404aca5feedcb54ef3;p=rspamd.git [Minor] Add method to find displayed urls --- 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