summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-08-21 15:58:53 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-08-21 15:58:53 +0100
commit40eb7a316af28b72c7a07042d6b8b7b1a06792b5 (patch)
tree413cc79562b1fe3d1a9fb9addc56a5768c7671c0
parent91d9f33e86b39737617d2d3fbc016673ba3b8cb1 (diff)
downloadrspamd-40eb7a316af28b72c7a07042d6b8b7b1a06792b5.tar.gz
rspamd-40eb7a316af28b72c7a07042d6b8b7b1a06792b5.zip
Fix whitespace parsing for rcl arrays.
-rw-r--r--src/rcl/rcl_parser.c23
-rw-r--r--test/rspamd_rcl_test.c9
2 files changed, 19 insertions, 13 deletions
diff --git a/src/rcl/rcl_parser.c b/src/rcl/rcl_parser.c
index 90202b6c5..797c8850c 100644
--- a/src/rcl/rcl_parser.c
+++ b/src/rcl/rcl_parser.c
@@ -573,7 +573,6 @@ rspamd_cl_parse_key (struct rspamd_cl_parser *parser,
else {
/* Invalid identifier */
rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "key must begin with a letter", err);
- assert (0);
return FALSE;
}
}
@@ -724,20 +723,22 @@ rspamd_cl_parse_value (struct rspamd_cl_parser *parser, struct rspamd_cl_chunk *
{
const guchar *p, *c;
struct rspamd_cl_stack *st;
- rspamd_cl_object_t *obj;
+ rspamd_cl_object_t *obj = NULL;
p = chunk->pos;
while (p < chunk->end) {
- if (parser->stack->obj->type == RSPAMD_CL_ARRAY) {
- /* Object must be allocated */
- obj = rspamd_cl_object_new ();
- parser->cur_obj = obj;
- LL_PREPEND (parser->stack->obj->value.ov, parser->cur_obj);
- }
- else {
- /* Object has been already allocated */
- obj = parser->cur_obj;
+ if (obj == NULL) {
+ if (parser->stack->obj->type == RSPAMD_CL_ARRAY) {
+ /* Object must be allocated */
+ obj = rspamd_cl_object_new ();
+ parser->cur_obj = obj;
+ LL_PREPEND (parser->stack->obj->value.ov, parser->cur_obj);
+ }
+ else {
+ /* Object has been already allocated */
+ obj = parser->cur_obj;
+ }
}
c = p;
switch (*p) {
diff --git a/test/rspamd_rcl_test.c b/test/rspamd_rcl_test.c
index 089f96452..c4e114409 100644
--- a/test/rspamd_rcl_test.c
+++ b/test/rspamd_rcl_test.c
@@ -34,7 +34,8 @@ const gchar *rcl_test_valid[] = {
"\"key1\": \"value;\""
"}\n",
/* Nginx like */
- "section1 { param1 = value; param2 = value, param3 = [\"value1\", value2, 100500]}\n"
+ "section1 { param1 = value; param2 = value, "
+ "section3 {param = value; param2 = value, param3 = [\"value1\", value2, 100500]}}\n"
"section2 { param1 = {key = value}, param1 = [\"key\"]}",
/* Numbers */
"key = 1s\n"
@@ -50,7 +51,11 @@ const gchar *rcl_test_valid[] = {
"key4: s1,"
"\"key5\": \"\\n\\r123\"",
/* Macros */
- "section1 {key = value; .include \"./test.cfg\"}",
+ "section1 {key = value; section {\n"
+ "param = \"value\";\n"
+ "param2 = value\n"
+ "array = [ 1, 1mb, test]}\n"
+ ".include \"./test.cfg\"}",
NULL
};