DEPENDS ${RAGEL_DEPENDS}
COMPILE_FLAGS -G2
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rfc2047.rl.c)
+RAGEL_TARGET(ragel_smtp_date
+ INPUTS ${CMAKE_SOURCE_DIR}/src/ragel/smtp_date_parser.rl
+ DEPENDS ${RAGEL_DEPENDS}
+ COMPILE_FLAGS -G2
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/date_parser.rl.c)
######################### LINK SECTION ###############################
ADD_LIBRARY(rspamd-server STATIC
"${RAGEL_ragel_newlines_strip_OUTPUTS}"
"${RAGEL_ragel_content_type_OUTPUTS}"
"${RAGEL_ragel_content_disposition_OUTPUTS}"
- "${RAGEL_ragel_rfc2047_OUTPUTS}")
+ "${RAGEL_ragel_rfc2047_OUTPUTS}"
+ "${RAGEL_ragel_smtp_date_OUTPUTS}")
TARGET_LINK_LIBRARIES(rspamd-server rspamd-http-parser)
TARGET_LINK_LIBRARIES(rspamd-server rspamd-cdb)
TARGET_LINK_LIBRARIES(rspamd-server rspamd-lpeg)
const gchar **charset, gsize *charset_len,
const gchar **encoded, gsize *encoded_len);
+guint64 rspamd_parse_smtp_date (const char *data, size_t len);
+
#endif /* SRC_LIBMIME_SMTP_PARSERS_H_ */
#include "utlist.h"
#include "cryptobox.h"
#include "unix-std.h"
+#include "libmime/smtp_parsers.h"
/***
* @module rspamd_task
if (hdrs && hdrs->len > 0) {
time_t tt;
- gint offset;
+ struct tm t;
struct rspamd_mime_header *h;
h = g_ptr_array_index (hdrs, 0);
- tt = g_mime_utils_header_decode_date (h->decoded, &offset);
+ tt = rspamd_parse_smtp_date (h->raw_value, h->raw_len);
if (!gmt) {
- tt += (offset * 60 * 60) / 100 + (offset * 60 * 60) % 100;
+ localtime_r (&tt, &t);
+#if !defined(__sun)
+ t.tm_gmtoff = 0;
+#endif
+ t.tm_isdst = 0;
+ tim = mktime (&t);
+ }
+ else {
+ tim = tt;
}
- tim = tt;
}
else {
tim = 0.0;
--- /dev/null
+%%{
+
+ machine smtp_date_parser;
+ include smtp_date "smtp_date.rl";
+
+ main := date_time;
+}%%
+
+#include "smtp_parsers.h"
+#include "util.h"
+
+%% write data;
+
+guint64
+rspamd_parse_smtp_date (const char *data, size_t len)
+{
+ const gchar *p = data, *pe = data + len, *eof = data + len, *tmp = data;
+ struct tm tm;
+ glong tz = 0;
+ gint cs = 0;
+
+ memset (&tm, 0, sizeof (tm));
+
+ %% write init;
+ %% write exec;
+
+ return rspamd_tm_to_time (&tm, tz);
+}
\ No newline at end of file