@@ -632,8 +632,6 @@ rspamd_message_from_data (struct rspamd_task *task, const guchar *start, | |||
gboolean | |||
rspamd_message_parse (struct rspamd_task *task) | |||
{ | |||
GPtrArray *hdrs; | |||
struct rspamd_mime_header *rh; | |||
struct rspamd_mime_text_part *p1, *p2; | |||
struct received_header *recv, *trecv; | |||
const gchar *p; | |||
@@ -824,13 +822,11 @@ rspamd_message_parse (struct rspamd_task *task) | |||
} | |||
/* Parse urls inside Subject header */ | |||
hdrs = rspamd_message_get_header_array (task, "Subject", FALSE); | |||
PTR_ARRAY_FOREACH (hdrs, i, rh) { | |||
p = rh->decoded; | |||
if (task->subject) { | |||
p = task->subject; | |||
len = strlen (p); | |||
rspamd_url_find_multiple (task->task_pool, p, len, FALSE, NULL, | |||
rspamd_url_task_callback, task); | |||
rspamd_url_task_subject_callback, task); | |||
} | |||
/* Calculate distance for 2-parts messages */ |
@@ -2486,7 +2486,7 @@ rspamd_url_find_single (rspamd_mempool_t *pool, const gchar *in, | |||
void | |||
rspamd_url_task_callback (struct rspamd_url *url, gsize start_offset, | |||
rspamd_url_task_subject_callback (struct rspamd_url *url, gsize start_offset, | |||
gsize end_offset, gpointer ud) | |||
{ | |||
struct rspamd_task *task = ud; | |||
@@ -2495,7 +2495,7 @@ rspamd_url_task_callback (struct rspamd_url *url, gsize start_offset, | |||
gint rc; | |||
/* It is just a displayed URL, we should not check it for certain things */ | |||
url->flags |= RSPAMD_URL_FLAG_HTML_DISPLAYED; | |||
url->flags |= RSPAMD_URL_FLAG_HTML_DISPLAYED|RSPAMD_URL_FLAG_SUBJECT; | |||
if (url->protocol == PROTOCOL_MAILTO) { | |||
if (url->userlen > 0) { |
@@ -16,6 +16,7 @@ enum rspamd_url_flags { | |||
RSPAMD_URL_FLAG_REDIRECTED = 1 << 3, | |||
RSPAMD_URL_FLAG_HTML_DISPLAYED = 1 << 4, | |||
RSPAMD_URL_FLAG_FROM_TEXT = 1 << 5, | |||
RSPAMD_URL_FLAG_SUBJECT = 1 << 6, | |||
}; | |||
struct rspamd_url_tag { | |||
@@ -163,7 +164,8 @@ void rspamd_url_find_single (rspamd_mempool_t *pool, const gchar *in, | |||
* @param end_offset | |||
* @param ud | |||
*/ | |||
void rspamd_url_task_callback (struct rspamd_url *url, gsize start_offset, | |||
void rspamd_url_task_subject_callback (struct rspamd_url *url, | |||
gsize start_offset, | |||
gsize end_offset, gpointer ud); | |||
/** |
@@ -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), | |||
@@ -339,6 +341,26 @@ lua_url_is_html_displayed (lua_State *L) | |||
return 1; | |||
} | |||
/*** | |||
* @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 |