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;
}
/* 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 */
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;
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) {
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 {
* @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);
/**
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);
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),
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