]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Allow parsing of mailbox messages from the commandline
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 23 Aug 2016 14:48:43 +0000 (15:48 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 23 Aug 2016 14:48:43 +0000 (15:48 +0100)
src/libmime/message.c
src/libserver/protocol.c
src/libserver/task.h

index 1f6356881302008850418a645c960ea725688552..a4c2d2ac0e73804b451e9dd1c6b799967354c45f 100644 (file)
@@ -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;
index 0ecc76ec667358330f7a54cd765af462f4e76650..5aff8f0cb9a7c1056f861bc34385618750ee375b 100644 (file)
@@ -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':
index f436c8275bd3cbda2d9ad970fd8489cce833625c..1d75e31dc1b6f34ccd0c9557562125a34f0aa53d 100644 (file)
@@ -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))