]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Feature] Store `for` part in received headers
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 4 Oct 2016 13:14:19 +0000 (14:14 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 4 Oct 2016 13:14:19 +0000 (14:14 +0100)
src/libmime/message.h
src/ragel/smtp_received.rl
src/ragel/smtp_received_parser.rl

index 2a9201be889bac9ac4032c429aaffbbf33d114f4..e38420dbff44a9ac459cd4ed10764e7298d6cde0 100644 (file)
@@ -84,6 +84,7 @@ struct received_header {
        gchar *real_hostname;
        gchar *real_ip;
        gchar *by_hostname;
+       gchar *for_mbox;
        rspamd_inet_addr_t *addr;
        time_t timestamp;
        enum rspamd_received_type type;
index e005dcc9ca3621c26d31452a4f5c70ed816b5275..c1fd46703753a7fab3ffae59624d02f366c9aea2 100644 (file)
@@ -44,7 +44,7 @@
   msg_id         = "<" id_left "@" id_right ">";
   ID             = CFWS "ID"i FWS ( Atom | msg_id );
 
-  For            = CFWS "FOR"i FWS ( Path | Mailbox ) %For_End;
+  For            = CFWS "FOR"i FWS ( Path | Mailbox ) >For_Start %For_End;
   Additional_Registered_Clauses  = CFWS Atom FWS String;
   Opt_info       = Via? With? ID? For? Additional_Registered_Clauses?;
   # Here we make From part optional just because many received headers lack it
index b2c73cab3d840069be3bde0e7e5ecd580e3dfb1f..c599e0495e081f20ac4a59e3812b6c97c5bb4aa9 100644 (file)
     reported_ip_end = NULL;
     ip_start = NULL;
     ip_end = NULL;
+    for_start = NULL;
+    for_end = NULL;
   }
 
   action By_Start {
     reported_ip_end = NULL;
     ip_start = NULL;
     ip_end = NULL;
+    for_start = NULL;
+    for_end = NULL;
   }
 
   action By_End {
     }
   }
 
-  action For_End {
+  action For_Start {
+    for_start = p;
+  }
 
+  action For_End {
+    if (for_start && p > for_start) {
+      for_end = p;
+      len = for_end - for_start;
+      rh->for_mbox = rspamd_mempool_alloc (task->task_pool, len + 1);
+      rspamd_strlcpy (rh->for_mbox, for_start, len + 1);
+    }
   }
 
   action SMTP_proto {
@@ -270,7 +283,8 @@ rspamd_smtp_recieved_parse (struct rspamd_task *task, const char *data, size_t l
               *real_ip_start, *real_ip_end,
               *reported_domain_start, *reported_domain_end,
               *reported_ip_start, *reported_ip_end,
-              *ip_start, *ip_end, *date_start;
+              *ip_start, *ip_end, *date_start,
+              *for_start, *for_end;
   const char *p = data, *pe = data + len, *eof;
   int cs, in_v6 = 0, *stack = NULL;
   gsize top = 0;
@@ -292,6 +306,8 @@ rspamd_smtp_recieved_parse (struct rspamd_task *task, const char *data, size_t l
   ip_start = NULL;
   ip_end = NULL;
   date_start = NULL;
+  for_start = NULL;
+  for_end = NULL;
   rh->type = RSPAMD_RECEIVED_UNKNOWN;
 
   memset (&for_addr, 0, sizeof (for_addr));