]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Couple of fixes for date parsing
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 21 Dec 2016 14:48:39 +0000 (14:48 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 21 Dec 2016 14:48:39 +0000 (14:48 +0000)
src/libutil/util.c
src/lua/lua_task.c
src/ragel/smtp_date.rl

index 0ddbaf9ef34860e11ebf2633c8ada71194308113..9d87d5c9ffce1487360f24d0171efecbe9e9ba82 100644 (file)
@@ -2654,7 +2654,7 @@ rspamd_tm_to_time (const struct tm *tm, glong tz)
        result += tm->tm_sec;
 
        /* Now apply tz offset */
-       result += offset;
+       result -= offset;
 
        return result;
 }
index 96c03847c61aff175927e6011eba3c76b2babb67..7e6ba5b102aa41505269938baf2b13845de8a587 100644 (file)
@@ -2596,7 +2596,7 @@ lua_task_get_date (lua_State *L)
                                struct rspamd_mime_header *h;
 
                                h = g_ptr_array_index (hdrs, 0);
-                               tt = rspamd_parse_smtp_date (h->raw_value, h->raw_len);
+                               tt = rspamd_parse_smtp_date (h->decoded, strlen (h->decoded));
 
                                if (!gmt) {
                                        localtime_r (&tt, &t);
index 23ab3cabaa3e79b6060a31d960f9b3e45ebec2f7..25e1ea3c09cb9228f087ddcb6affd64437ef7d83 100644 (file)
       gulong n;
       if (rspamd_strtoul (tmp, p - tmp, &n)) {
         if (n < 1000) {
-          tm.tm_year = n + 1900;
+          tm.tm_year = n;
         }
         else {
-          tm.tm_year = n;
+          tm.tm_year = n - 1900;
         }
       }
     }
   day_name        =    "Mon" | "Tue" | "Wed" | "Thu" |
                        "Fri" | "Sat" | "Sun";
   day_of_week     =   FWS? day_name;
-  day             =   FWS? digit{1,2} FWS;
+  day             =   FWS? digit{1,2} >Day_Start %Day_End FWS;
   month           =    "Jan" %Month_Jan | "Feb" %Month_Feb | "Mar" %Month_Mar | "Apr" %Month_Apr |
                        "May" %Month_May | "Jun" %Month_Jun | "Jul" %Month_Jul | "Aug" %Month_Aug |
                        "Sep" %Month_Sep | "Oct" %Month_Oct | "Nov" %Month_Nov | "Dec" %Month_Dec;
-  year            =   FWS digit{2,} FWS;
-  date            =   day >Day_Start %Day_End month %Month_End year >Year_Start %Year_End;
+  year            =   FWS digit{2,4} >Year_Start %Year_End FWS;
+  date            =   day month %Month_End year;
   hour            =   digit_2;
   minute          =   digit_2;
   second          =   digit_2;