blob: b5b4863d33857b48d99fd1c2b2d60d6b83c3768a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
%%{
machine smtp_addr_parser;
action IP6_start {}
action IP6_end {}
action IP4_start {}
action IP4_end {}
action User_start {
addr->user = p;
}
action User_end {
if (addr->user) {
addr->user_len = p - addr->user;
}
}
action Domain_start {
addr->domain = p;
}
action Domain_end {
if (addr->domain) {
addr->domain_len = p - addr->domain;
}
}
action Domain_addr_start {
addr->domain = p;
addr->flags |= RSPAMD_EMAIL_ADDR_IP;
}
action Domain_addr_end {
if (addr->domain) {
addr->domain_len = p - addr->domain;
}
}
action User_has_backslash {
addr->flags |= RSPAMD_EMAIL_ADDR_HAS_BACKSLASH;
}
action Quoted_addr {
addr->flags |= RSPAMD_EMAIL_ADDR_QUOTED;
}
action Empty_addr {
addr->flags |= RSPAMD_EMAIL_ADDR_EMPTY|RSPAMD_EMAIL_ADDR_VALID;
addr->addr = "";
addr->user = addr->addr;
addr->domain = addr->addr;
}
action Valid_addr {
if (addr->addr_len > 0) {
addr->flags |= RSPAMD_EMAIL_ADDR_VALID;
}
}
action Addr_has_angle {
addr->flags |= RSPAMD_EMAIL_ADDR_BRACED;
}
action Addr_start {
addr->addr = p;
}
action Addr_end {
if (addr->addr) {
addr->addr_len = p - addr->addr;
}
}
include smtp_base "smtp_base.rl";
include smtp_ip "smtp_ip.rl";
include smtp_address "smtp_address.rl";
main := SMTPAddr;
}%%
#include "smtp_parsers.h"
%% write data;
int
rspamd_smtp_addr_parse (const char *data, size_t len, struct rspamd_email_address *addr)
{
const char *p = data, *pe = data + len, *eof;
int cs;
g_assert (addr != NULL);
memset (addr, 0, sizeof (*addr));
addr->raw = data;
addr->raw_len = len;
eof = pe;
%% write init;
%% write exec;
return cs;
}
|