From d6c5bdb0f9f1a2a2c152dc63142678ad3a673d0a Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sat, 14 May 2016 10:22:19 +0800 Subject: [PATCH] lejp handle name elements starting with dot Signed-off-by: Andy Green --- lib/lejp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/lejp.c b/lib/lejp.c index 20a0734..74b39ef 100644 --- a/lib/lejp.c +++ b/lib/lejp.c @@ -115,7 +115,15 @@ lejp_check_path_match(struct lejp_ctx *ctx) } ctx->wild[ctx->wildcount++] = p - ctx->path; q++; - while (*p && *p != '.') + /* + * if * has something after it, match to . + * if ends with *, eat everything. + * This implies match sequences must be ordered like + * x.*.* + * x.* + * if both options are possible + */ + while (*p && (*p != '.' || !*q)) p++; } if (*p || *q) @@ -140,7 +148,7 @@ lejp_get_wildcard(struct lejp_ctx *ctx, int wildcard, char *dest, int len) n = ctx->wild[wildcard]; - while (--len && n < ctx->ppos && ctx->path[n] != '.') + while (--len && n < ctx->ppos && (n == ctx->wild[wildcard] || ctx->path[n] != '.')) *dest++ = ctx->path[n++]; *dest = '\0'; -- 2.7.4