aboutsummaryrefslogtreecommitdiffstats
path: root/src/ragel
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-04 14:14:19 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-04 14:14:19 +0100
commit4ae5dc6bf798912b865ee7a25faedcacbf5841a4 (patch)
tree6409789e0725948f0a49cd6e6612ba7f88f8de20 /src/ragel
parent1a90df75a2a60731004faeef8f5442b2ea83ed9d (diff)
downloadrspamd-4ae5dc6bf798912b865ee7a25faedcacbf5841a4.tar.gz
rspamd-4ae5dc6bf798912b865ee7a25faedcacbf5841a4.zip
[Feature] Store `for` part in received headers
Diffstat (limited to 'src/ragel')
-rw-r--r--src/ragel/smtp_received.rl2
-rw-r--r--src/ragel/smtp_received_parser.rl20
2 files changed, 19 insertions, 3 deletions
diff --git a/src/ragel/smtp_received.rl b/src/ragel/smtp_received.rl
index e005dcc9c..c1fd46703 100644
--- a/src/ragel/smtp_received.rl
+++ b/src/ragel/smtp_received.rl
@@ -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
diff --git a/src/ragel/smtp_received_parser.rl b/src/ragel/smtp_received_parser.rl
index b2c73cab3..c599e0495 100644
--- a/src/ragel/smtp_received_parser.rl
+++ b/src/ragel/smtp_received_parser.rl
@@ -142,6 +142,8 @@
reported_ip_end = NULL;
ip_start = NULL;
ip_end = NULL;
+ for_start = NULL;
+ for_end = NULL;
}
action By_Start {
@@ -155,6 +157,8 @@
reported_ip_end = NULL;
ip_start = NULL;
ip_end = NULL;
+ for_start = NULL;
+ for_end = NULL;
}
action By_End {
@@ -210,8 +214,17 @@
}
}
- 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));