Browse Source

Add is_obscured method for lua url API

tags/1.1.0
Vsevolod Stakhov 8 years ago
parent
commit
2cd0e1c61c
1 changed files with 22 additions and 0 deletions
  1. 22
    0
      src/lua/lua_url.c

+ 22
- 0
src/lua/lua_url.c View File

@@ -57,6 +57,7 @@ LUA_FUNCTION_DEF (url, get_text);
LUA_FUNCTION_DEF (url, get_tld);
LUA_FUNCTION_DEF (url, to_table);
LUA_FUNCTION_DEF (url, is_phished);
LUA_FUNCTION_DEF (url, is_obscured);
LUA_FUNCTION_DEF (url, get_phished);
LUA_FUNCTION_DEF (url, create);
LUA_FUNCTION_DEF (url, all);
@@ -73,6 +74,7 @@ static const struct luaL_reg urllib_m[] = {
LUA_INTERFACE_DEF (url, get_tld),
LUA_INTERFACE_DEF (url, to_table),
LUA_INTERFACE_DEF (url, is_phished),
LUA_INTERFACE_DEF (url, is_obscured),
LUA_INTERFACE_DEF (url, get_phished),
{"__tostring", lua_url_get_text},
{NULL, NULL}
@@ -270,6 +272,26 @@ lua_url_is_phished (lua_State *L)
return 1;
}

/***
* @method url:is_obscured()
* Check whether URL is treated as obscured or obfusicated (e.g. numbers in IP address or other hacks)
* @return {boolean} `true` if URL is obscured
*/
static gint
lua_url_is_obscured (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_OBSCURED);
}
else {
lua_pushnil (L);
}

return 1;
}

/***
* @method url:get_phished()
* Get another URL that pretends to be this URL (e.g. used in phishing)

Loading…
Cancel
Save