From: Arran Cudbard-Bell Date: Sat, 5 Sep 2015 21:36:00 +0000 (-0400) Subject: Allow %} as an expansion for a literal } Closes #1209 X-Git-Tag: release_3_0_10~161 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d216dfba7e8a5f69f7b13cc1cc499c1f09d69075;p=thirdparty%2Ffreeradius-server.git Allow %} as an expansion for a literal } Closes #1209 --- diff --git a/src/main/xlat.c b/src/main/xlat.c index 4b1a9cefa80..c077e3d139a 100644 --- a/src/main/xlat.c +++ b/src/main/xlat.c @@ -1454,7 +1454,7 @@ static ssize_t xlat_tokenize_literal(TALLOC_CTX *ctx, char *fmt, xlat_exp_t **he ssize_t slen; xlat_exp_t *next; - if (!p[1] || !strchr("%dlmntDGHISTYv", p[1])) { + if (!p[1] || !strchr("%}dlmntDGHISTYv", p[1])) { talloc_free(node); *error = "Invalid variable expansion"; p++; @@ -1464,17 +1464,21 @@ static ssize_t xlat_tokenize_literal(TALLOC_CTX *ctx, char *fmt, xlat_exp_t **he next = talloc_zero(node, xlat_exp_t); next->len = 1; - if (p[1] == '%') { - next->fmt = talloc_typed_strdup(next, "%"); + switch (p[1]) { + case '%': + case '}': + next->fmt = talloc_strndup(next, p + 1, 1); - XLAT_DEBUG("LITERAL-PERCENT <-- %s", next->fmt); + XLAT_DEBUG("LITERAL-ESCAPED <-- %s", next->fmt); next->type = XLAT_LITERAL; + break; - } else { + default: next->fmt = p + 1; XLAT_DEBUG("PERCENT <-- %c", *next->fmt); next->type = XLAT_PERCENT; + break; } node->next = next;