Sat, 04 Apr 2015 22:20:39 +0200
parser verifies that path is an identifier
libidav/davqlparser.c | file | annotate | diff | comparison | revisions | |
libidav/davqlparser.h | file | annotate | diff | comparison | revisions |
--- a/libidav/davqlparser.c Sat Apr 04 22:06:42 2015 +0200 +++ b/libidav/davqlparser.c Sat Apr 04 22:20:39 2015 +0200 @@ -251,6 +251,7 @@ #define _unknown_attribute "unknown attribute '%.*s'" #define _duplicated_attribute "duplicated attribute '%.*s'" #define _invalid_depth "invalid depth" +#define _identifier_expected "identifier expected, but found: %.*s" static UcxList* dav_parse_tokenize(sstr_t src) { UcxList *tokens = NULL; @@ -422,7 +423,7 @@ /* * 1: depth */ - int key = 0; + static int key = 0; static int keymask = 0; switch (parsestate) { @@ -565,7 +566,13 @@ case 20: { DavQLExpression *expr = dav_parse_expression(stmt, token, 1); stmt->path = expr->srctext; + int exprtype = expr->type; dav_free_expression(expr); + if (exprtype != DAVQL_IDENTIFIER) { + stmt->errorcode = DAVQL_ERROR_IDENTIFIER_EXPECTED; + stmt->errormessage = ucx_sprintf(_identifier_expected, + sfmtarg(tokendata)).ptr; + } step = 530; break; }
--- a/libidav/davqlparser.h Sat Apr 04 22:06:42 2015 +0200 +++ b/libidav/davqlparser.h Sat Apr 04 22:20:39 2015 +0200 @@ -207,6 +207,9 @@ /** Infinity recursion depth for a DavQLStatement. */ #define DAV_DEPTH_INFINITY -1 +/** Expected an identifier, but found something else. */ +#define DAVQL_ERROR_IDENTIFIER_EXPECTED 10 + /** The with-clause contains an unknown attribute. */ #define DAVQL_ERROR_UNKNOWN_ATTRIBUTE 20