summaryrefslogtreecommitdiffstats
path: root/src/message.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-03-23 20:14:08 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-03-23 20:14:08 +0300
commit7c3c86ce3fad9d222561fddc3bb30e7f1aa66b32 (patch)
tree2c114a98f6f3a261a23b7f0e812eb9fe37c8b945 /src/message.c
parent143e584d81e18757922706ae67f9fd61e85a10d1 (diff)
downloadrspamd-7c3c86ce3fad9d222561fddc3bb30e7f1aa66b32.tar.gz
rspamd-7c3c86ce3fad9d222561fddc3bb30e7f1aa66b32.zip
* Add ability to extract urls from subject field0.3.10
Fix phishing plugin. * Important fix for multimap/cdb handling * Important fix for phishing detector
Diffstat (limited to 'src/message.c')
-rw-r--r--src/message.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/message.c b/src/message.c
index 4f4627351..48eb4d89c 100644
--- a/src/message.c
+++ b/src/message.c
@@ -945,7 +945,10 @@ process_message (struct worker_task *task)
GMimePart *part;
GMimeDataWrapper *wrapper;
struct received_header *recv;
- gchar *mid;
+ gchar *mid, *url_str, *p, *end;
+ struct uri *subject_url;
+ gsize len;
+ gint pos, rc;
tmp = memory_pool_alloc (task->task_pool, sizeof (GByteArray));
tmp->data = task->msg->begin;
@@ -1090,6 +1093,44 @@ process_message (struct worker_task *task)
#endif
}
+ /* Parse urls inside Subject header */
+ cur = message_get_header (task->task_pool, task->message, "Subject", FALSE);
+ if (cur) {
+ p = cur->data;
+ len = strlen (p);
+ end = p + len;
+
+ while (p < end) {
+ /* Search to the end of url */
+ if (url_try_text (task->task_pool, p, end - p, &pos, &url_str)) {
+ if (url_str != NULL) {
+ subject_url = memory_pool_alloc0 (task->task_pool, sizeof (struct uri));
+ if (subject_url != NULL) {
+ /* Try to parse url */
+ rc = parse_uri (subject_url, url_str, task->task_pool);
+ if ((rc == URI_ERRNO_OK || rc == URI_ERRNO_NO_SLASHES || rc == URI_ERRNO_NO_HOST_SLASH) &&
+ subject_url->hostlen > 0) {
+ if (subject_url->protocol != PROTOCOL_MAILTO) {
+ if (!g_tree_lookup (task->urls, subject_url)) {
+ g_tree_insert (task->urls, subject_url, subject_url);
+ }
+ }
+ }
+ else if (rc != URI_ERRNO_OK) {
+ msg_info ("extract of url '%s' failed: %s", url_str, url_strerror (rc));
+ }
+ }
+ }
+ }
+ else {
+ break;
+ }
+ p += pos;
+ }
+ /* Free header's list */
+ g_list_free (cur);
+ }
+
return 0;
}