aboutsummaryrefslogtreecommitdiffstats
path: root/src/cfg_utils.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-03-18 20:03:36 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-03-18 20:03:36 +0300
commit9c455404d443c748b6398076c1746a12a7458bfc (patch)
tree1f6174f446b4257291ef723b4f43ad9f06b7931d /src/cfg_utils.c
parent8cc22288806b9ff7115cb8f30349029714e2d89a (diff)
downloadrspamd-9c455404d443c748b6398076c1746a12a7458bfc.tar.gz
rspamd-9c455404d443c748b6398076c1746a12a7458bfc.zip
* Allow escaped quotes in quoted strings, for example "\"some string\""
* Add warnings when we got errors while parsing rexeps
Diffstat (limited to 'src/cfg_utils.c')
-rw-r--r--src/cfg_utils.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/cfg_utils.c b/src/cfg_utils.c
index 204ed65f6..f95237e59 100644
--- a/src/cfg_utils.c
+++ b/src/cfg_utils.c
@@ -567,6 +567,7 @@ parse_regexp (memory_pool_t *pool, char *line)
line ++;
}
if (line == '\0') {
+ msg_warn ("parse_regexp: got empty regexp");
return NULL;
}
/* First try to find header name */
@@ -593,6 +594,7 @@ parse_regexp (memory_pool_t *pool, char *line)
}
else {
/* We got header name earlier but have not found // expression, so it is invalid regexp */
+ msg_warn ("parse_regexp: got no header name (eg. header=) but without corresponding regexp");
return NULL;
}
/* Find end */
@@ -601,6 +603,7 @@ parse_regexp (memory_pool_t *pool, char *line)
end ++;
}
if (end == begin || *end != '/') {
+ msg_warn ("parse_regexp: no trailing / in regexp");
return NULL;
}
/* Parse flags */
@@ -675,6 +678,11 @@ parse_regexp (memory_pool_t *pool, char *line)
memory_pool_add_destructor (pool, (pool_destruct_func)g_regex_unref, (void *)result->regexp);
*end = '/';
+ if (result->regexp == NULL || err != NULL) {
+ msg_warn ("parse_regexp: could not read regexp: %s", err->message);
+ return NULL;
+ }
+
return result;
}
@@ -712,6 +720,22 @@ parse_warn (const char *fmt, ...)
g_warning ("%s", logbuf);
}
+void
+unescape_quotes (char *line)
+{
+ char *c = line, *t;
+
+ while (*c) {
+ if (*c == '\\' && *(c + 1) == '"') {
+ t = c;
+ while (*t) {
+ *t = *(t + 1);
+ t ++;
+ }
+ }
+ c ++;
+ }
+}
/*
* vi:ts=4