}
if (errno == ERANGE) {
rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "numeric value is out of range", err);
+ parser->prev_state = parser->state;
parser->state = RSPAMD_RCL_STATE_ERROR;
return FALSE;
}
}
else {
/* Invalid identifier */
- parser->state = RSPAMD_RCL_STATE_ERROR;
rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "key must begin with a letter", err);
return FALSE;
}
p = chunk->pos;
while (chunk->pos < chunk->end) {
+ parser->prev_state = parser->state;
switch (parser->state) {
case RSPAMD_RCL_STATE_INIT:
/*
* a key of newly created object
*/
if (!rspamd_cl_skip_comments (parser, err)) {
+ parser->prev_state = parser->state;
parser->state = RSPAMD_RCL_STATE_ERROR;
return FALSE;
}
continue;
}
if (!rspamd_cl_parse_key (parser, chunk, err)) {
+ parser->prev_state = parser->state;
parser->state = RSPAMD_RCL_STATE_ERROR;
return FALSE;
}
rspamd_cl_chunk_skipc (chunk, *p);
p ++;
if (!rspamd_cl_lex_json_string (parser, chunk, err)) {
+ parser->prev_state = parser->state;
parser->state = RSPAMD_RCL_STATE_ERROR;
return FALSE;
}
break;
default:
/* Skip any spaces and comments */
- while (p < chunk->end && g_ascii_isspace (*p)) {
- rspamd_cl_chunk_skipc (chunk, *p);
- p ++;
- }
- if ((p[0] == '/' && p[1] == '/') || *p == '#') {
+ if (g_ascii_isspace (*p) ||
+ (p[0] == '/' && p[1] == '/') || *p == '#') {
+ while (p < chunk->end && g_ascii_isspace (*p)) {
+ rspamd_cl_chunk_skipc (chunk, *p);
+ p ++;
+ }
if (!rspamd_cl_skip_comments (parser, err)) {
return FALSE;
}
p = chunk->pos;
+ continue;
}
/* Parse atom */
if (g_ascii_isdigit (*p) || *p == '-') {
}
else {
if (!rspamd_cl_parse_string_value (parser, chunk, err)) {
+ parser->prev_state = parser->state;
parser->state = RSPAMD_RCL_STATE_ERROR;
return FALSE;
}
else if ((p[0] == '/' && p[1] == '/') || *p == '#') {
/* Skip comment */
if (!rspamd_cl_skip_comments (parser, err)) {
+ parser->prev_state = parser->state;
parser->state = RSPAMD_RCL_STATE_ERROR;
return FALSE;
}
/* Got a separator */
got_sep = TRUE;
if (got_comma || got_semicolon) {
- rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "uexpected comma detected", err);
+ rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "unexpected comma detected", err);
+ parser->prev_state = parser->state;
parser->state = RSPAMD_RCL_STATE_ERROR;
return FALSE;
}
got_sep = TRUE;
if (got_comma || got_semicolon) {
rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "unexpected semicolon detected", err);
+ parser->prev_state = parser->state;
parser->state = RSPAMD_RCL_STATE_ERROR;
return FALSE;
}
else if (*p == '}' || *p == ']') {
if (parser->stack == NULL) {
rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "unexpected } detected", err);
+ parser->prev_state = parser->state;
parser->state = RSPAMD_RCL_STATE_ERROR;
return FALSE;
}
}
else {
rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "unexpected terminating symbol detected", err);
+ parser->prev_state = parser->state;
parser->state = RSPAMD_RCL_STATE_ERROR;
return FALSE;
}
/* Anything else */
if (!got_sep) {
rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "delimiter is missing", err);
+ parser->prev_state = parser->state;
parser->state = RSPAMD_RCL_STATE_ERROR;
return FALSE;
}
/* Test config emitting */
emitted = rspamd_cl_object_emit (obj, RSPAMD_CL_EMIT_CONFIG);
g_assert (emitted != NULL);
- msg_info ("got config output: %s", emitted);
+ msg_debug ("got config output: %s", emitted);
parser2 = rspamd_cl_parser_new ();
g_assert (parser2 != NULL);
rspamd_cl_parser_add_chunk (parser2, emitted, strlen (emitted), &err);
/* Test json emitted */
emitted = rspamd_cl_object_emit (obj, RSPAMD_CL_EMIT_JSON);
g_assert (emitted != NULL);
- msg_info ("got json output: %s", emitted);
+ msg_debug ("got json output: %s", emitted);
parser2 = rspamd_cl_parser_new ();
g_assert (parser2 != NULL);
rspamd_cl_parser_add_chunk (parser2, emitted, strlen (emitted), &err);
/* Compact json */
emitted = rspamd_cl_object_emit (obj, RSPAMD_CL_EMIT_JSON_COMPACT);
g_assert (emitted != NULL);
- msg_info ("got json compacted output: %s", emitted);
+ msg_debug ("got json compacted output: %s", emitted);
parser2 = rspamd_cl_parser_new ();
g_assert (parser2 != NULL);
rspamd_cl_parser_add_chunk (parser2, emitted, strlen (emitted), &err);