]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Further relax parser
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 15 Jun 2016 16:08:43 +0000 (17:08 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 15 Jun 2016 16:08:43 +0000 (17:08 +0100)
src/ragel/smtp_received.rl
utils/received_parser_bench.c

index 67a52e7cffcfd47c097dafc489e71d075ddc6a57..f4a0ed7ba9440ca2a7e3356eeff8360b5358e2d3 100644 (file)
@@ -23,7 +23,8 @@
                   ( Domain >Real_Domain_Start %Real_Domain_End FWS address_literal >Real_IP_Start %Real_IP_End );
   Extended_Domain  = Domain >Real_Domain_Start %Real_Domain_End | # Used to be a real domain
                   ( Domain >Reported_Domain_Start %Reported_Domain_End FWS "(" TCP_info ")" ) | # Here domain is something specified by remote side
-                  ( address_literal >Real_Domain_Start %Real_Domain_End FWS "(" TCP_info ")" );
+                  ( address_literal >Real_Domain_Start %Real_Domain_End FWS "(" TCP_info ")" ) |
+                  address_literal >Real_IP_Start %Real_IP_End; # Not RFC conforming, but many MTA try this
 
   ccontent = ctext | FWS | '(' @{ fcall balanced_ccontent; };
   balanced_ccontent := ccontent* ')' @{ fret; };
@@ -31,7 +32,7 @@
   CFWS           =   ((FWS? comment)+ FWS?) | FWS;
 
   From_domain    = "FROM"i FWS Extended_Domain >From_Start %From_End;
-  By_domain      = CFWS "BY"i FWS Extended_Domain >By_Start %By_End;
+  By_domain      = "BY"i FWS Extended_Domain >By_Start %By_End;
 
   Via            = CFWS "VIA"i FWS Link;
   With           = CFWS "WITH"i FWS Protocol;
@@ -45,7 +46,8 @@
   For            = CFWS "FOR"i FWS ( Path | Mailbox ) %For_End;
   Additional_Registered_Clauses  = CFWS Atom FWS String;
   Opt_info       = Via? With? ID? For? Additional_Registered_Clauses?;
-  Received       = From_domain By_domain Opt_info CFWS? ";" FWS date_time >Date_Start %Date_End CFWS?;
+  # Here we make From part optional just because many received headers lack it
+  Received       = From_domain? CFWS? By_domain? CFWS? Opt_info CFWS? ";" FWS date_time >Date_Start %Date_End CFWS?;
 
   prepush {
     if (top >= st_storage.size) {
index 4f6a073fdc863204234b1a8015923a090d2355d1..cb304b631874923d0e43799301b96b19ba157894 100644 (file)
@@ -75,7 +75,7 @@ rspamd_process_file (const gchar *fname)
                        total_known_proto ++;
                }
 
-               if (rh.by_hostname) {
+               if (rh.by_hostname || rh.timestamp > 0) {
                        total_valid ++;
                }