diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-05-31 22:10:50 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-05-31 22:10:50 +0400 |
commit | 68e60c48745e40038e9a123fe9381b86d0b1534e (patch) | |
tree | e214906210ab7cf17392c4389335a2bad0f08b82 /src/map.c | |
parent | 5293ff7c9fbcb67b2aeadce9934cfde009dce2fe (diff) | |
download | rspamd-68e60c48745e40038e9a123fe9381b86d0b1534e.tar.gz rspamd-68e60c48745e40038e9a123fe9381b86d0b1534e.zip |
* Allow keys without values in kv maps
Some fixes to dkim_check strict logic.
Diffstat (limited to 'src/map.c')
-rw-r--r-- | src/map.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -587,23 +587,35 @@ abstract_parse_kv_list (memory_pool_t * pool, gchar * chunk, gint len, struct ma /* read key */ /* Check here comments, eol and end of buffer */ if (*p == '#') { - if (key != NULL && p - c > 0) { + if (key != NULL && p - c >= 0) { value = memory_pool_alloc (pool, p - c + 1); memcpy (value, c, p - c); value[p - c] = '\0'; value = g_strstrip (value); func (data->cur_data, key, value); + msg_debug ("insert kv pair: %s -> %s", key, value); } data->state = 99; } else if (*p == '\r' || *p == '\n' || p - chunk == len - 1) { - if (key != NULL && p - c > 0) { + if (key != NULL && p - c >= 0) { value = memory_pool_alloc (pool, p - c + 1); memcpy (value, c, p - c); value[p - c] = '\0'; value = g_strstrip (value); func (data->cur_data, key, value); + msg_debug ("insert kv pair: %s -> %s", key, value); + } + else if (key == NULL && p - c > 0) { + /* Key only line */ + key = memory_pool_alloc (pool, p - c + 1); + memcpy (key, c, p - c); + key[p - c] = '\0'; + value = memory_pool_alloc (pool, 1); + *value = '\0'; + func (data->cur_data, key, value); + msg_debug ("insert kv pair: %s -> %s", key, value); } data->state = 100; key = NULL; |