aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-23 15:48:43 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-23 15:48:43 +0100
commit0b4c54e21874d6d622ab6820e36071c071e0c3e1 (patch)
tree6304c29b9a455e7b029ec33a95f1b4fc2ab4f72c /src
parent0f67ab52981f2c96abd2a43b9768b8e2df1eb777 (diff)
downloadrspamd-0b4c54e21874d6d622ab6820e36071c071e0c3e1.tar.gz
rspamd-0b4c54e21874d6d622ab6820e36071c071e0c3e1.zip
[Feature] Allow parsing of mailbox messages from the commandline
Diffstat (limited to 'src')
-rw-r--r--src/libmime/message.c8
-rw-r--r--src/libserver/protocol.c7
-rw-r--r--src/libserver/task.h1
3 files changed, 10 insertions, 6 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index 1f6356881..a4c2d2ac0 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -1401,7 +1401,8 @@ rspamd_message_parse (struct rspamd_task *task)
* So we check if a task has non-http format then we check for such a line
* at the beginning to avoid errors
*/
- if (!(task->flags & RSPAMD_TASK_FLAG_JSON)) {
+ if (!(task->flags & RSPAMD_TASK_FLAG_JSON) || (task->flags &
+ RSPAMD_TASK_FLAG_LOCAL_CLIENT)) {
if (len > sizeof ("From ") - 1) {
if (memcmp (p, "From ", sizeof ("From ") - 1) == 0) {
/* Skip to CRLF */
@@ -1719,11 +1720,6 @@ rspamd_message_parse (struct rspamd_task *task)
"message contains two parts but they are in different multi-parts");
}
}
- else {
- debug_task (
- "message has too many text parts, so do not try to compare "
- "them with each other");
- }
for (i = 0; i < task->parts->len; i ++) {
struct rspamd_mime_part *part;
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 0ecc76ec6..5aff8f0cb 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -96,6 +96,7 @@
#define DELIVER_TO_HEADER "Deliver-To"
#define NO_LOG_HEADER "Log"
#define MLEN_HEADER "Message-Length"
+#define USER_AGENT_HEADER "User-Agent"
static GQuark
@@ -438,6 +439,12 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
debug_task ("extended urls information");
}
}
+ IF_HEADER (USER_AGENT_HEADER) {
+ if (hv_tok->len == 6 &&
+ rspamd_lc_cmp (hv_tok->begin, "rspamc", 6) == 0) {
+ task->flags |= RSPAMD_TASK_FLAG_LOCAL_CLIENT;
+ }
+ }
break;
case 'l':
case 'L':
diff --git a/src/libserver/task.h b/src/libserver/task.h
index f436c8275..1d75e31dc 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -103,6 +103,7 @@ enum rspamd_task_stage {
#define RSPAMD_TASK_FLAG_HAS_SPAM_TOKENS (1 << 20)
#define RSPAMD_TASK_FLAG_HAS_HAM_TOKENS (1 << 21)
#define RSPAMD_TASK_FLAG_EMPTY (1 << 22)
+#define RSPAMD_TASK_FLAG_LOCAL_CLIENT (1 << 23)
#define RSPAMD_TASK_IS_SKIPPED(task) (((task)->flags & RSPAMD_TASK_FLAG_SKIP))
#define RSPAMD_TASK_IS_JSON(task) (((task)->flags & RSPAMD_TASK_FLAG_JSON))