aboutsummaryrefslogtreecommitdiffstats
path: root/src/ragel/smtp_address.rl
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-23 11:33:18 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-23 14:45:27 +0100
commit6832271dbc2771c7e3b2512fef2dcc054ab55c49 (patch)
tree5e7c944fabf2bcb92f8be6aa5e70d8940ba05167 /src/ragel/smtp_address.rl
parentd4c86a2cd8a4f326870079d1bcf1cc2b005deec4 (diff)
downloadrspamd-6832271dbc2771c7e3b2512fef2dcc054ab55c49.tar.gz
rspamd-6832271dbc2771c7e3b2512fef2dcc054ab55c49.zip
[Feature] Add parsers for SMTP address in ragel
Diffstat (limited to 'src/ragel/smtp_address.rl')
-rw-r--r--src/ragel/smtp_address.rl50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/ragel/smtp_address.rl b/src/ragel/smtp_address.rl
new file mode 100644
index 000000000..c0333acd9
--- /dev/null
+++ b/src/ragel/smtp_address.rl
@@ -0,0 +1,50 @@
+%%{
+ machine smtp_address;
+
+ include smtp_ip "smtp_ip.rl";
+
+ # SMTP address spec
+ # Obtained from: https://tools.ietf.org/html/rfc5321#section-4.1.2
+
+ LF = "\n";
+ CR = "\r";
+ CRLF = "\r\n";
+ DQUOTE = '"';
+
+ atext = alpha | digit | "!" | "#" | "$" | "%" | "&" |
+ "'" | "*" | "+" | "_" | "/" | "=" | "?" | "^" |
+ "_" | "`" | "{" | "|" | "}" | "~";
+
+ dcontent = 33..90 | 94..126;
+ Let_dig = alpha | digit;
+ Ldh_str = ( alpha | digit | "_" )* Let_dig;
+
+ quoted_pairSMTP = "\\" 32..126;
+ qtextSMTP = 32..33 | 35..91 | 93..126;
+ Atom = atext+;
+ Dot_string = Atom ("." Atom)*;
+
+ QcontentSMTP = qtextSMTP | quoted_pairSMTP;
+ Quoted_string = ( DQUOTE QcontentSMTP* DQUOTE ) %Quoted_addr;
+ Local_part = ( Dot_string | Quoted_string ) >User_start %User_end;
+ String = Atom | Quoted_string;
+
+ Standardized_tag = Ldh_str;
+ General_address_literal = Standardized_tag ":" dcontent+;
+ address_literal = "[" ( IPv4_address_literal |
+ IPv6_address_literal |
+ General_address_literal ) >Domain_addr_start %Domain_addr_end "]";
+
+
+ sub_domain = Let_dig Ldh_str?;
+ Domain = sub_domain ("." sub_domain)*;
+ Atdomain = "@" Domain;
+ Adl = Atdomain ( "," Atdomain )*;
+
+ Mailbox = Local_part "@" (address_literal | Domain >Domain_start %Domain_end);
+ UnangledPath = ( Adl ":" )? Mailbox;
+ AngledPath = "<" UnangledPath ">";
+ Path = AngledPath %Angled_addr | UnangledPath;
+ SMTPAddr = space* (Path | "<>" %Empty_addr ) %Valid_addr space*;
+
+}%%