Browse Source

[Minor] Warn about get_date misuse

tags/1.6.0
Vsevolod Stakhov 7 years ago
parent
commit
5af7c8321b
1 changed files with 16 additions and 9 deletions
  1. 16
    9
      src/lua/lua_task.c

+ 16
- 9
src/lua/lua_task.c View File

}; };


static enum lua_date_type static enum lua_date_type
lua_task_detect_date_type (lua_State *L, gint idx, gboolean *gmt)
lua_task_detect_date_type (struct rspamd_task *task,
lua_State *L, gint idx, gboolean *gmt)
{ {
enum lua_date_type type = DATE_CONNECT; enum lua_date_type type = DATE_CONNECT;


lua_pushvalue (L, idx); lua_pushvalue (L, idx);
lua_pushstring (L, "format"); lua_pushstring (L, "format");
lua_gettable (L, -2); lua_gettable (L, -2);

str = lua_tostring (L, -1); str = lua_tostring (L, -1);
if (g_ascii_strcasecmp (str, "message") == 0) {
type = DATE_MESSAGE;
}
else if (g_ascii_strcasecmp (str, "connect_str") == 0) {
type = DATE_CONNECT_STRING;

if (str) {
if (g_ascii_strcasecmp (str, "message") == 0) {
type = DATE_MESSAGE;
} else if (g_ascii_strcasecmp (str, "connect_str") == 0) {
type = DATE_CONNECT_STRING;
} else if (g_ascii_strcasecmp (str, "message_str") == 0) {
type = DATE_MESSAGE_STRING;
}
} }
else if (g_ascii_strcasecmp (str, "message_str") == 0) {
type = DATE_MESSAGE_STRING;
else {
msg_warn_task ("date format has not been specified");
} }

lua_pop (L, 1); lua_pop (L, 1);


lua_pushstring (L, "gmt"); lua_pushstring (L, "gmt");


if (task != NULL) { if (task != NULL) {
if (lua_gettop (L) > 1) { if (lua_gettop (L) > 1) {
type = lua_task_detect_date_type (L, 2, &gmt);
type = lua_task_detect_date_type (task, L, 2, &gmt);
} }
/* Get GMT date and store it to time_t */ /* Get GMT date and store it to time_t */
if (type == DATE_CONNECT || type == DATE_CONNECT_STRING) { if (type == DATE_CONNECT || type == DATE_CONNECT_STRING) {

Loading…
Cancel
Save