};
-$to_blah = "To=/blah@blah/H";
+$to_blah = "To=/\"blah@blah\"/H";
$from_blah = "From=/blah@blah/H";
$subject_blah = "Subject=/blah/H";
*/
struct expression* parse_expression (memory_pool_t *pool, char *line);
+/**
+ * Replace all \" with a single " in given string
+ * @param line input string
+ */
+void unescape_quotes (char *line);
+
int yylex (void);
int yyparse (void);
void yyrestart (FILE *);
yes|YES|no|NO|[yY]|[nN] yylval.flag=parse_flag(yytext); return FLAG;
\n /* ignore EOL */;
[ \t]+ /* ignore whitespace */;
-\"[^"]+\" yylval.string=strdup(yytext + 1); yylval.string[strlen(yylval.string) - 1] = '\0'; return QUOTEDSTRING;
+\".+[^\\]\" yylval.string=strdup(yytext + 1); yylval.string[strlen(yylval.string) - 1] = '\0'; unescape_quotes(yylval.string); return QUOTEDSTRING;
\" return QUOTE;
\$[a-zA-Z_][a-zA-Z0-9_]+ yylval.string=strdup(yytext + 1); return VARIABLE;
[0-9]+ yylval.number=strtol(yytext, NULL, 10); return NUMBER;
<module>= return EQSIGN;
<module>[a-zA-Z0-9_%-]+ yylval.string=strdup(yytext); return PARAM;
<module>\$[a-zA-Z_][a-zA-Z0-9_]+ yylval.string=strdup(yytext + 1); return VARIABLE;
-<module>\"[^"]+\" yylval.string=strdup(yytext + 1); yylval.string[strlen(yylval.string) - 1] = '\0'; return QUOTEDSTRING;
+<module>\".+[^\\]\" yylval.string=strdup(yytext + 1); yylval.string[strlen(yylval.string) - 1] = '\0'; unescape_quotes(yylval.string); return QUOTEDSTRING;
%%
/*
line ++;
}
if (line == '\0') {
+ msg_warn ("parse_regexp: got empty regexp");
return NULL;
}
/* First try to find header name */
}
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 */
end ++;
}
if (end == begin || *end != '/') {
+ msg_warn ("parse_regexp: no trailing / in regexp");
return NULL;
}
/* Parse flags */
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;
}
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
struct expression *e, *cur;
e = parse_expression (regexp_module_ctx->regexp_pool, line);
+ if (e == NULL) {
+ msg_err ("read_regexp_extension: %s is invalid regexp extension", line);
+ }
chain->expr = e;
cur = e;
while (cur) {