From 44d9cd1d59b340e8111ae57dafd06f65734b12d1 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 23 Feb 2011 20:21:38 +0300 Subject: [PATCH] Save separator inside raw_header struct. Requested by: Victor Ustugov --- src/lua/lua_task.c | 4 ++++ src/message.c | 15 +++++++++++++++ src/message.h | 2 ++ 3 files changed, 21 insertions(+) diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 16b59efe4..48db4c833 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -358,6 +358,10 @@ lua_task_get_raw_header_common (lua_State * L, gboolean strong) lua_pushstring (L, "tab_separated"); lua_pushboolean (L, rh->tab_separated); lua_settable (L, -3); + lua_pushstring (L, "empty_separator"); + lua_pushboolean (L, rh->empty_separator); + lua_settable (L, -3); + lua_set_table_index (L, "separator", rh->separator); lua_rawseti (L, -2, i++); /* Process next element */ cur = g_list_next (cur); diff --git a/src/message.c b/src/message.c index 38f9a663e..2056e87ca 100644 --- a/src/message.c +++ b/src/message.c @@ -499,6 +499,7 @@ process_raw_headers (struct worker_task *task) new->name = tmp; p ++; state = 2; + c = p; } else if (g_ascii_isspace (*p)) { /* Not header but some garbadge */ @@ -513,20 +514,34 @@ process_raw_headers (struct worker_task *task) /* We got header's name, so skip any \t or spaces */ if (*p == '\t') { new->tab_separated = TRUE; + new->empty_separator = FALSE; p ++; } else if (*p == ' '){ + new->empty_separator = FALSE; p ++; } else if (*p == '\n' || *p == '\r') { /* Process folding */ state = 99; + l = p - c - 1; + if (l > 0) { + tmp = memory_pool_alloc (task->task_pool, l + 1); + rspamd_strlcpy (tmp, c, l + 1); + new->separator = tmp; + } next_state = 3; err_state = 5; c = p; } else { /* Process value */ + l = p - c - 1; + if (l > 0) { + tmp = memory_pool_alloc (task->task_pool, l + 1); + rspamd_strlcpy (tmp, c, l + 1); + new->separator = tmp; + } c = p; state = 3; } diff --git a/src/message.h b/src/message.h index e5859738a..7ac598460 100644 --- a/src/message.h +++ b/src/message.h @@ -49,6 +49,8 @@ struct raw_header { gchar *name; gchar *value; gboolean tab_separated; + gboolean empty_separator; + gchar *separator; }; /** -- 2.39.5