]> source.dussan.org Git - rspamd.git/commitdiff
Make keys syntax more permissive.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 14 Oct 2013 22:44:22 +0000 (23:44 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 14 Oct 2013 22:44:22 +0000 (23:44 +0100)
src/rcl/rcl_chartable.h
src/rcl/rcl_parser.c

index 6dc82cbd601532153b8fd3cf9fc663468f1061a8..2c02c954622db3c16c5b9cf0625cbc3c053ae157 100644 (file)
@@ -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 */,
index d00b2d3ebeb1f6a702f53135d5bd91aea5cb1be8..0b69d25bc71951ae92cd95a0d2c151065b972366 100644 (file)
@@ -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);