aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_url.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-28 14:25:56 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-03-28 14:25:56 +0100
commit4174974c5cf7f1ba10667f858d96f9ba5795db09 (patch)
tree9acfa55f3dd1bb57c65374a321c3dd468dc0094b /src/lua/lua_url.c
parent7ab6c1b73821caf33d8931206a7fb01cab09b45d (diff)
downloadrspamd-4174974c5cf7f1ba10667f858d96f9ba5795db09.tar.gz
rspamd-4174974c5cf7f1ba10667f858d96f9ba5795db09.zip
[Feature] Distinguish URLs found in Subject
Diffstat (limited to 'src/lua/lua_url.c')
-rw-r--r--src/lua/lua_url.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c
index 9b69267a4..8826bb41c 100644
--- a/src/lua/lua_url.c
+++ b/src/lua/lua_url.c
@@ -53,6 +53,7 @@ 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, is_subject);
LUA_FUNCTION_DEF (url, get_phished);
LUA_FUNCTION_DEF (url, get_tag);
LUA_FUNCTION_DEF (url, get_tags);
@@ -76,6 +77,7 @@ static const struct luaL_reg urllib_m[] = {
LUA_INTERFACE_DEF (url, is_redirected),
LUA_INTERFACE_DEF (url, is_obscured),
LUA_INTERFACE_DEF (url, is_html_displayed),
+ LUA_INTERFACE_DEF (url, is_subject),
LUA_INTERFACE_DEF (url, get_phished),
LUA_INTERFACE_DEF (url, get_tag),
LUA_INTERFACE_DEF (url, get_tags),
@@ -340,6 +342,26 @@ lua_url_is_html_displayed (lua_State *L)
}
/***
+ * @method url:is_subject()
+ * Check whether URL is found in subject
+ * @return {boolean} `true` if URL is found in subject
+ */
+static gint
+lua_url_is_subject (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_SUBJECT);
+ }
+ else {
+ lua_pushnil (L);
+ }
+
+ return 1;
+}
+
+/***
* @method url:get_tag(tag)
* Returns list of string for a specific tagname for an url
* @return {table/strings} list of tags for an url