From 555b81de0bc69d3b542d05fadb8a5f2b786bc9e0 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 14 Oct 2013 23:44:22 +0100 Subject: [PATCH] Make keys syntax more permissive. --- src/rcl/rcl_chartable.h | 26 +++++++++++++------------- src/rcl/rcl_parser.c | 32 ++++++++++++++++---------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/rcl/rcl_chartable.h b/src/rcl/rcl_chartable.h index 6dc82cbd6..2c02c9546 100644 --- a/src/rcl/rcl_chartable.h +++ b/src/rcl/rcl_chartable.h @@ -49,18 +49,18 @@ RCL_CHARACTER_VALUE_STR /* ) */, RCL_CHARACTER_VALUE_STR /* * */, RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT /* + */, RCL_CHARACTER_VALUE_END /* , */, RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* - */, -RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT /* . */, -RCL_CHARACTER_VALUE_STR /* / */, -RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 0 */, -RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 1 */, -RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 2 */, -RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 3 */, -RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 4 */, -RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 5 */, -RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 6 */, -RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 7 */, -RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 8 */, -RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 9 */, +RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT /* . */, +RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR /* / */, +RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 0 */, +RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 1 */, +RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 2 */, +RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 3 */, +RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 4 */, +RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 5 */, +RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 6 */, +RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 7 */, +RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 8 */, +RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT_START|RCL_CHARACTER_VALUE_DIGIT /* 9 */, RCL_CHARACTER_VALUE_STR /* : */, RCL_CHARACTER_VALUE_END /* ; */, RCL_CHARACTER_VALUE_STR /* < */, RCL_CHARACTER_VALUE_STR /* = */, RCL_CHARACTER_VALUE_STR /* > */, RCL_CHARACTER_VALUE_STR /* ? */, @@ -93,7 +93,7 @@ RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_ RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT /* Z */, RCL_CHARACTER_VALUE_STR /* [ */, RCL_CHARACTER_VALUE_STR /* \ */, RCL_CHARACTER_VALUE_END /* ] */, RCL_CHARACTER_VALUE_STR /* ^ */, -RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR /* _ */, +RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR /* _ */, RCL_CHARACTER_VALUE_STR /* ` */, RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT /* a */, RCL_CHARACTER_KEY_START|RCL_CHARACTER_KEY|RCL_CHARACTER_VALUE_STR|RCL_CHARACTER_VALUE_DIGIT /* b */, diff --git a/src/rcl/rcl_parser.c b/src/rcl/rcl_parser.c index d00b2d3eb..0b69d25bc 100644 --- a/src/rcl/rcl_parser.c +++ b/src/rcl/rcl_parser.c @@ -529,19 +529,25 @@ rspamd_cl_parse_key (struct rspamd_cl_parser *parser, p = chunk->pos; + if (*p == '.') { + /* It is macro actually */ + rspamd_cl_chunk_skipc (chunk, *p); + parser->prev_state = parser->state; + parser->state = RSPAMD_RCL_STATE_MACRO_NAME; + return TRUE; + } while (p < chunk->end) { /* - * A key must start with alpha and end with space character + * A key must start with alpha, number, '/' or '_' and end with space character */ - if (*p == '.') { - /* It is macro actually */ - rspamd_cl_chunk_skipc (chunk, *p); - parser->prev_state = parser->state; - parser->state = RSPAMD_RCL_STATE_MACRO_NAME; - return TRUE; - } - else if (c == NULL) { - if (rcl_test_character (*p, RCL_CHARACTER_KEY_START)) { + if (c == NULL) { + if (rspamd_cl_lex_is_comment (p[0], p[1])) { + if (!rspamd_cl_skip_comments (parser, err)) { + return FALSE; + } + p = chunk->pos; + } + else if (rcl_test_character (*p, RCL_CHARACTER_KEY_START)) { /* The first symbol */ c = p; rspamd_cl_chunk_skipc (chunk, *p); @@ -554,12 +560,6 @@ rspamd_cl_parse_key (struct rspamd_cl_parser *parser, rspamd_cl_chunk_skipc (chunk, *p); p ++; } - else if (rspamd_cl_lex_is_comment (p[0], p[1])) { - if (!rspamd_cl_skip_comments (parser, err)) { - return FALSE; - } - p = chunk->pos; - } else { /* Invalid identifier */ rspamd_cl_set_err (chunk, RSPAMD_CL_ESYNTAX, "key must begin with a letter", err); -- 2.39.5