diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-08-12 18:04:13 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-08-12 20:26:17 +0100 |
commit | 809d57ec6a1152b040a24c2ede1d22c5effc0dcb (patch) | |
tree | b498358e699fa270fd4277ba460459f6f1fdf2bf /src/lua/lua_url.c | |
parent | 9f825e53d329e67a15f77d09b546e8f840e81fa8 (diff) | |
download | rspamd-809d57ec6a1152b040a24c2ede1d22c5effc0dcb.tar.gz rspamd-809d57ec6a1152b040a24c2ede1d22c5effc0dcb.zip |
[Minor] Store raw urls
Diffstat (limited to 'src/lua/lua_url.c')
-rw-r--r-- | src/lua/lua_url.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c index 15966bfa3..cbe9148a3 100644 --- a/src/lua/lua_url.c +++ b/src/lua/lua_url.c @@ -47,6 +47,7 @@ LUA_FUNCTION_DEF (url, get_path); LUA_FUNCTION_DEF (url, get_query); LUA_FUNCTION_DEF (url, get_fragment); LUA_FUNCTION_DEF (url, get_text); +LUA_FUNCTION_DEF (url, get_raw); LUA_FUNCTION_DEF (url, get_tld); LUA_FUNCTION_DEF (url, to_table); LUA_FUNCTION_DEF (url, is_phished); @@ -73,6 +74,7 @@ static const struct luaL_reg urllib_m[] = { LUA_INTERFACE_DEF (url, get_fragment), LUA_INTERFACE_DEF (url, get_text), LUA_INTERFACE_DEF (url, get_tld), + LUA_INTERFACE_DEF (url, get_raw), LUA_INTERFACE_DEF (url, to_table), LUA_INTERFACE_DEF (url, is_phished), LUA_INTERFACE_DEF (url, is_redirected), @@ -263,6 +265,26 @@ lua_url_get_text (lua_State *L) } /*** + * @method url:get_raw() + * Get full content of the url as it was parsed (e.g. with urldecode) + * @return {string} url string + */ +static gint +lua_url_get_raw (lua_State *L) +{ + struct rspamd_lua_url *url = lua_check_url (L, 1); + + if (url != NULL) { + lua_pushlstring (L, url->url->raw, url->url->rawlen); + } + else { + lua_pushnil (L); + } + + return 1; +} + +/*** * @method url:is_phished() * Check whether URL is treated as phished * @return {boolean} `true` if URL is phished |